Debian Codegraph @

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

raw
1 // Copyright (C) 2019 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-aggregate-error
6 description: >
7 Abrupt completions of ToString(message)
8 info: |
9 AggregateError ( errors, message )
10
11 ...
12 5. If message is not undefined, then
13 a. Let msg be ? ToString(message).
14 b. Perform ! CreateMethodProperty(O, "message", msg).
15 6. Return O.
16 features: [AggregateError, Symbol.toPrimitive]
17 ---*/
18
19 var case1 = {
20 [Symbol.toPrimitive]() {
21 throw new Test262Error();
22 },
23 toString() {
24 throw 'toString called';
25 },
26 valueOf() {
27 throw 'valueOf called';
28 }
29 };
30
31 assert.throws(Test262Error, () => {
32 new AggregateError([], case1);
33 }, 'toPrimitive');
34
35 var case2 = {
36 [Symbol.toPrimitive]: undefined,
37 toString() {
38 throw new Test262Error();
39 },
40 valueOf() {
41 throw 'valueOf called';
42 }
43 };
44
45 assert.throws(Test262Error, () => {
46 new AggregateError([], case2);
47 }, 'toString');
48
49 var case3 = {
50 [Symbol.toPrimitive]: undefined,
51 toString: undefined,
52 valueOf() {
53 throw new Test262Error();
54 }
55 };
56
57 assert.throws(Test262Error, () => {
58 new AggregateError([], case3);
59 }, 'valueOf');
60
61 reportCompare(0, 0);