Debian Codegraph @

js/src/jit-test/tests/wasm/exceptions/stack.js

raw
1 let tag = new WebAssembly.Tag({parameters: []});
2
3 function construct(options) {
4 return new WebAssembly.Exception(tag, [], options);
5 }
6 function noStack(options) {
7 assertEq(construct(options).stack, undefined, 'no stack');
8 }
9 function hasStack(options) {
10 assertEq(typeof construct(options).stack === 'string', true, 'has stack');
11 }
12
13 // Test valid option constructors
14 noStack(undefined);
15 noStack(null);
16 noStack({});
17 noStack({traceStack: false});
18 noStack({traceStack: 0});
19 hasStack({traceStack: true});
20 hasStack({traceStack: 1});
21
22 // Test invalid option constructors
23 assertErrorMessage(() => construct('not an object'), TypeError, /cannot be converted/);
24
25 // Test that 'stack' is read-only
26 let exception = construct({traceStack: true});
27 exception.stack = 0;
28 assertEq(typeof exception.stack === 'string', true, 'is read-only');