Debian Codegraph @

js/src/jit-test/tests/explicit-resource-management/async-disposable-stack-properties.js

raw
1 // |jit-test| skip-if: !getBuildConfiguration("explicit-resource-management"); --enable-explicit-resource-management
2
3 load(libdir + "asserts.js");
4
5 {
6 assertEq(typeof AsyncDisposableStack, "function");
7
8 assertDeepEq(Object.getOwnPropertyDescriptor(AsyncDisposableStack, 'prototype'), {
9 value: AsyncDisposableStack.prototype,
10 writable: false,
11 enumerable: false,
12 configurable: false,
13 });
14 }
15
16 {
17 assertDeepEq(Object.getOwnPropertyDescriptor(AsyncDisposableStack.prototype, Symbol.toStringTag), {
18 value: 'AsyncDisposableStack',
19 writable: false,
20 enumerable: false,
21 configurable: true
22 });
23 }
24
25 {
26 assertEq(typeof AsyncDisposableStack.prototype[Symbol.asyncDispose], 'function');
27 assertEq(AsyncDisposableStack.prototype[Symbol.asyncDispose], AsyncDisposableStack.prototype.disposeAsync);
28 assertDeepEq(Object.getOwnPropertyDescriptor(AsyncDisposableStack.prototype, Symbol.asyncDispose), {
29 value: AsyncDisposableStack.prototype[Symbol.asyncDispose],
30 writable: true,
31 enumerable: false,
32 configurable: true,
33 });
34 }
35
36 {
37 assertThrowsInstanceOf(() => AsyncDisposableStack(), TypeError);
38 }
39
40 {
41 const properties = ['adopt', 'defer', 'move', 'disposed', 'use'];
42 for (const p of properties) {
43 assertThrowsInstanceOf(() => {
44 AsyncDisposableStack.prototype[p].call({});
45 }, TypeError);
46 }
47
48 const asyncProperties = ['disposeAsync', Symbol.asyncDispose];
49 for (const p of asyncProperties) {
50 assertThrowsInstanceOfAsync(async () => {
51 await AsyncDisposableStack.prototype[p].call({});
52 }, TypeError);
53 }
54 }