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.
54 lines
1.2 KiB
54 lines
1.2 KiB
7 years ago
|
/*===
|
||
|
*** test_1 (duk_safe_call)
|
||
|
==> rc=0, result='undefined'
|
||
|
*** test_2 (duk_safe_call)
|
||
|
==> rc=1, result='TypeError: object required, found null (stack index 0)'
|
||
|
*** test_3 (duk_safe_call)
|
||
|
==> rc=1, result='TypeError: object required, found none (stack index 0)'
|
||
|
*** test_4 (duk_safe_call)
|
||
|
==> rc=1, result='TypeError: object required, found none (stack index -2147483648)'
|
||
|
===*/
|
||
|
|
||
|
static duk_ret_t test_1(duk_context *ctx, void *udata) {
|
||
|
(void) udata;
|
||
|
|
||
|
duk_set_top(ctx, 0);
|
||
|
duk_push_object(ctx);
|
||
|
duk_require_object(ctx, 0);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
static duk_ret_t test_2(duk_context *ctx, void *udata) {
|
||
|
(void) udata;
|
||
|
|
||
|
duk_set_top(ctx, 0);
|
||
|
duk_push_null(ctx);
|
||
|
duk_require_object(ctx, 0);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
static duk_ret_t test_3(duk_context *ctx, void *udata) {
|
||
|
(void) udata;
|
||
|
|
||
|
duk_set_top(ctx, 0);
|
||
|
duk_require_object(ctx, 0);
|
||
|
printf("require 0 OK\n");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
static duk_ret_t test_4(duk_context *ctx, void *udata) {
|
||
|
(void) udata;
|
||
|
|
||
|
duk_set_top(ctx, 0);
|
||
|
duk_require_object(ctx, DUK_INVALID_INDEX);
|
||
|
printf("require DUK_INVALID_INDEX OK\n");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void test(duk_context *ctx) {
|
||
|
TEST_SAFE_CALL(test_1);
|
||
|
TEST_SAFE_CALL(test_2);
|
||
|
TEST_SAFE_CALL(test_3);
|
||
|
TEST_SAFE_CALL(test_4);
|
||
|
}
|