summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js')
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js
new file mode 100644
index 0000000000..1c356d719a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-aggregate-error
+description: >
+ Abrupt completions of ToString(message)
+info: |
+ AggregateError ( errors, message )
+
+ ...
+ 5. If message is not undefined, then
+ a. Let msg be ? ToString(message).
+ b. Perform ! CreateMethodProperty(O, "message", msg).
+ 6. Return O.
+features: [AggregateError, Symbol.toPrimitive]
+---*/
+
+var case1 = {
+ [Symbol.toPrimitive]() {
+ throw new Test262Error();
+ },
+ toString() {
+ throw 'toString called';
+ },
+ valueOf() {
+ throw 'valueOf called';
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new AggregateError([], case1);
+}, 'toPrimitive');
+
+var case2 = {
+ [Symbol.toPrimitive]: undefined,
+ toString() {
+ throw new Test262Error();
+ },
+ valueOf() {
+ throw 'valueOf called';
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new AggregateError([], case2);
+}, 'toString');
+
+var case3 = {
+ [Symbol.toPrimitive]: undefined,
+ toString: undefined,
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new AggregateError([], case3);
+}, 'valueOf');
+
+reportCompare(0, 0);