/*
 *  Test that we can continue after a catchstack limit error.
 */

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

/*===
RangeError: catchstack limit
true
still here
===*/

/* The current limits for callstack and catchstack are the same
 * (10000), so a recursive call with more than one catcher should
 * ensure that the catchstack is exhausted first.
 *
 * This only works (= hits catchstack limit) if valstack limit is
 * significantly higher (currently 100000).
 */

function f1() {
    try {
        try {
            try {
                try {
                    f1();
                } finally {
                }
            } finally {
            }
        } finally {
        }
    } finally {
    }
}

try {
    f1();
} catch (e) {
    print(e.name + ': ' + e.message);

    // ensure that it is indeed the catchstack which failed; Rhino and V8
    // will fail this test of course
    print(/catch/i.test(e.message));
}

print('still here');

/*===
6765
===*/

/* Test that we can continue normally.  Just a simple recursive call test here. */

function fib(x) {
    if (x == 0) { return 0; }
    if (x == 1) { return 1; }
    return fib(x - 1) + fib(x - 2);
}

try {
    print(fib(20));
} catch (e) {
    print(e.name);
}

@@ -60,18 +60,325 @@
 rror.%0A *
-/
 %0A
+ *  Since Duktape 2.2.0 there isn't an explicit catch stack limit: catchers%0A *  are allocated normally and an out-of-memory may occur when trying to%0A *  allocate a catcher.  This test would now fail with callstack limit and%0A *  is disabled.%0A */%0A%0A// Skipped since Duktape 2.2.0: no explicit catchstack limits.
 %0A/*---%0A%7B
@@ -391,16 +391,34 @@
 custom%22:
+ true,%0A    %22skip%22:
  true%0A%7D%0A
@@ -444,19 +444,18 @@
 rror: ca
-tch
+ll
 stack li

Test case fixes for duk_catcher rework