mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
855 B
33 lines
855 B
/*===
|
|
rc=0, result='21'
|
|
top after pop: 0
|
|
rc=1, result='Error: my error'
|
|
top after pop: 0
|
|
final top: 0
|
|
===*/
|
|
|
|
void test(duk_context *ctx) {
|
|
int rc;
|
|
|
|
/* basic success case */
|
|
duk_eval_string(ctx, "(function (x,y) { return x+y; })");
|
|
duk_push_int(ctx, 10);
|
|
duk_push_int(ctx, 11);
|
|
rc = duk_pcall(ctx, 2, DUK_INVALID_INDEX);
|
|
printf("rc=%d, result='%s'\n", rc, duk_to_string(ctx, -1));
|
|
duk_pop(ctx);
|
|
printf("top after pop: %d\n", duk_get_top(ctx));
|
|
|
|
/* basic error case */
|
|
duk_eval_string(ctx, "(function (x,y) { throw new Error('my error'); })");
|
|
duk_push_int(ctx, 10);
|
|
duk_push_int(ctx, 11);
|
|
rc = duk_pcall(ctx, 2, DUK_INVALID_INDEX);
|
|
printf("rc=%d, result='%s'\n", rc, duk_to_string(ctx, -1));
|
|
duk_pop(ctx);
|
|
printf("top after pop: %d\n", duk_get_top(ctx));
|
|
|
|
/* FIXME: error handler tests */
|
|
|
|
printf("final top: %d\n", duk_get_top(ctx));
|
|
}
|
|
|