Browse Source

API test update for literal pinning

pull/1814/head
Sami Vaarala 7 years ago
parent
commit
dd4698b161
  1. 17
      tests/api/test-push-literal.c

17
tests/api/test-push-literal.c

@ -77,6 +77,23 @@ static duk_ret_t test_basic(duk_context *ctx, void *udata) {
printf("len: %ld\n", (long) len);
duk_pop(ctx);
/* Push a literal (which pins it temporarily), force mark-and-sweep to
* free it, repush, etc. This exercises freeing of temporarily pinned
* literals, and is useful for assertion testing.
*/
(void) duk_push_literal(ctx, "canBeCollected");
duk_pop(ctx);
duk_gc(ctx, 0);
duk_gc(ctx, 0);
(void) duk_push_literal(ctx, "canBeCollected");
duk_pop(ctx);
duk_gc(ctx, 0);
duk_gc(ctx, 0);
(void) duk_push_literal(ctx, "canBeCollected");
duk_pop(ctx);
duk_gc(ctx, 0);
duk_gc(ctx, 0);
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}

Loading…
Cancel
Save