MCPcopy Create free account
hub / github.com/buke/quickjs-go / is_array

Function is_array

deps/quickjs/api-test.c:310–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310static void is_array(void)
311{
312 JSRuntime *rt = new_runtime();
313 JSContext *ctx = JS_NewContext(rt);
314 {
315 JSValue ret = eval(ctx, "[]");
316 assert(!JS_IsException(ret));
317 assert(JS_IsArray(ret));
318 JS_FreeValue(ctx, ret);
319 }
320 {
321 JSValue ret = eval(ctx, "new Proxy([], {})");
322 assert(!JS_IsException(ret));
323 assert(!JS_IsArray(ret));
324 assert(JS_IsProxy(ret));
325 JSValue handler = JS_GetProxyHandler(ctx, ret);
326 JSValue target = JS_GetProxyTarget(ctx, ret);
327 assert(!JS_IsException(handler));
328 assert(!JS_IsException(target));
329 assert(!JS_IsProxy(handler));
330 assert(!JS_IsProxy(target));
331 assert(JS_IsObject(handler));
332 assert(JS_IsArray(target));
333 JS_FreeValue(ctx, handler);
334 JS_FreeValue(ctx, target);
335 JS_FreeValue(ctx, ret);
336 }
337 JS_FreeContext(ctx);
338 JS_FreeRuntime(rt);
339}
340
341static int loader_calls;
342

Callers 1

mainFunction · 0.85

Calls 5

new_runtimeFunction · 0.85
evalFunction · 0.85
JS_IsExceptionFunction · 0.85
JS_IsObjectFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected