Debian Codegraph @

js/src/tests/test262/built-ins/NativeErrors/SuppressedError/message-tostring-abrupt-symbol.js

raw
1 // |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) -- explicit-resource-management is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2023 Ron Buckton. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-suppressederror-constructor
7 description: >
8 Abrupt completions of ToString(Symbol message)
9 info: |
10 SuppressedError ( error, suppressed, message )
11
12 ...
13 5. If message is not undefined, then
14 a. Let msg be ? ToString(message).
15 b. Perform ! CreateMethodProperty(O, "message", msg).
16 6. Return O.
17 features: [explicit-resource-management, Symbol, Symbol.toPrimitive]
18 ---*/
19
20 var case1 = Symbol();
21
22 assert.throws(TypeError, () => {
23 new SuppressedError(undefined, undefined, case1);
24 }, 'toPrimitive');
25
26 var case2 = {
27 [Symbol.toPrimitive]() {
28 return Symbol();
29 },
30 toString() {
31 throw new Test262Error();
32 },
33 valueOf() {
34 throw new Test262Error();
35 }
36 };
37
38 assert.throws(TypeError, () => {
39 new SuppressedError(undefined, undefined, case2);
40 }, 'from ToPrimitive');
41
42 reportCompare(0, 0);