/*
 *  https://github.com/svaarala/duktape/issues/111
 */

/*---
{
    "custom": true
}
---*/

/*===
65534
Error
Error
Error
===*/

function test(n) {
    var res = [];
    var i;
    var fn;

    res.push('(function func() { ');
    for (i = 0; i < n; i++) {
        res.push('    var arg' + i + ' = ' + i + ';');
    }
    res.push('    return arg' + (i - 1) + ';');
    res.push('})');

    res = res.join('\n');

    fn = eval(res);
    return fn();
}

try {
    print(test(65535));  // should work
} catch (e) {
    print(e.name);
}

try {
    print(test(65536));  // should be rejected with internal error now
} catch (e) {
    print(e.name);
}

try {
    print(test(262143));  // should be rejected with internal error now
} catch (e) {
    print(e.name);
}

try {
    print(test(262144));  // should be rejected with internal error now
} catch (e) {
    print(e.name);
}

@@ -98,17 +98,17 @@
 ===%0A6553
-4
+1
 %0AError%0AE
@@ -476,16 +476,20 @@
 st(65535
+ - 3
 ));  // 
@@ -499,16 +499,37 @@
 uld work
+, -3 for shuffle regs
 %0A%7D catch
@@ -583,16 +583,20 @@
 st(65536
+ - 3
 ));  // 
@@ -701,16 +701,20 @@
 t(262143
+ - 3
 ));  // 
@@ -819,16 +819,20 @@
 t(262144
+ - 3
 ));  // 

Fix testcase to match reg shuffle fix