summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/NativeErrors/AggregateError
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/NativeErrors/AggregateError
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/NativeErrors/AggregateError')
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/cause-property.js41
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist-failures.js185
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js71
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/is-a-constructor.js26
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/length.js34
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop-cast.js71
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop.js35
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt-symbol.js41
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt.js61
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-undefined-no-prop.js35
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/name.js35
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-is-undefined.js21
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-custom.js49
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-fallback.js60
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto.js37
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/order-of-args-evaluation.js43
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prop-desc.js28
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto-from-ctor-realm.js60
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto.js18
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/constructor.js27
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/errors-absent-on-prototype.js21
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/message.js27
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/name.js26
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/proto.js18
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/shell.js101
29 files changed, 1197 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/browser.js
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/cause-property.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/cause-property.js
new file mode 100644
index 0000000000..f06df10541
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/cause-property.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-aggregate-error
+description: >
+ AggregateError constructor creates own cause property
+info: |
+ AggregateError ( errors, message[ , options ] )
+
+ ...
+ 4. Perform ? InstallErrorCause(O, options).
+ ...
+
+ InstallErrorCause ( O, options )
+
+ 1. If Type(options) is Object and ? HasProperty(options, "cause") is true, then
+ a. Let cause be ? Get(options, "cause").
+ b. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "cause", cause).
+ ...
+
+features: [AggregateError, error-cause]
+includes: [propertyHelper.js]
+---*/
+
+var errors = [];
+var message = "my-message";
+var cause = { message: "my-cause" };
+var error = new AggregateError(errors, message, { cause });
+
+verifyProperty(error, "cause", {
+ configurable: true,
+ enumerable: false,
+ writable: true,
+ value: cause,
+});
+
+verifyProperty(new AggregateError(errors, message), "cause", undefined);
+verifyProperty(new AggregateError(errors, message, { cause: undefined }), "cause", { value: undefined });
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist-failures.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist-failures.js
new file mode 100644
index 0000000000..c1ae1b37c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist-failures.js
@@ -0,0 +1,185 @@
+// 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: >
+ Return abrupt completion from IterableToList(errors)
+info: |
+ AggregateError ( errors, message )
+
+ ...
+ 3. Let errorsList be ? IterableToList(errors).
+ 4. Set O.[[AggregateErrors]] to errorsList.
+ ...
+ 6. Return O.
+
+ Runtime Semantics: IterableToList ( items [ , method ] )
+
+ 1. If method is present, then
+ ...
+ 2. Else,
+ b. Let iteratorRecord be ? GetIterator(items, sync).
+ 3. Let values be a new empty List.
+ 4. Let next be true.
+ 5. Repeat, while next is not false
+ a. Set next to ? IteratorStep(iteratorRecord).
+ b. If next is not false, then
+ i. Let nextValue be ? IteratorValue(next).
+ ii. Append nextValue to the end of the List values.
+ 6. Return values.
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ 6. Let nextMethod be ? GetV(iterator, "next").
+ ...
+ 8. Return iteratorRecord.
+features: [AggregateError, Symbol.iterator]
+---*/
+
+var case1 = {
+ get [Symbol.iterator]() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ var obj = new AggregateError(case1);
+}, 'get Symbol.iterator');
+
+var case2 = {
+ get [Symbol.iterator]() {
+ return {};
+ }
+};
+
+assert.throws(TypeError, () => {
+ var obj = new AggregateError(case2);
+}, 'GetMethod(obj, @@iterator) abrupts from non callable');
+
+var case3 = {
+ [Symbol.iterator]() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ var obj = new AggregateError(case3);
+}, 'Abrupt from @@iterator call');
+
+var case4 = {
+ [Symbol.iterator]() {
+ return 'a string';
+ }
+};
+
+assert.throws(TypeError, () => {
+ var obj = new AggregateError(case4);
+}, '@@iterator call returns a string');
+
+var case5 = {
+ [Symbol.iterator]() {
+ return undefined;
+ }
+};
+
+assert.throws(TypeError, () => {
+ var obj = new AggregateError(case5);
+}, '@@iterator call returns undefined');
+
+var case6 = {
+ [Symbol.iterator]() {
+ return {
+ get next() {
+ throw new Test262Error();
+ }
+ }
+ }
+};
+
+assert.throws(Test262Error, () => {
+ var obj = new AggregateError(case6);
+}, 'GetV(iterator, next) returns abrupt');
+
+var case7 = {
+ [Symbol.iterator]() {
+ return {
+ get next() {
+ return {};
+ }
+ }
+ }
+};
+
+assert.throws(TypeError, () => {
+ var obj = new AggregateError(case7);
+}, 'GetV(iterator, next) returns a non callable');
+
+var case8 = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ }
+ }
+};
+
+assert.throws(Test262Error, () => {
+ var obj = new AggregateError(case8);
+}, 'abrupt from iterator.next()');
+
+var case9 = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ return undefined;
+ }
+ }
+ }
+};
+
+assert.throws(TypeError, () => {
+ var obj = new AggregateError(case9);
+}, 'iterator.next() returns undefined');
+
+var case10 = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ return 'a string';
+ }
+ }
+ }
+};
+
+assert.throws(TypeError, () => {
+ var obj = new AggregateError(case10);
+}, 'iterator.next() returns a string');
+
+var case11 = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ return {
+ get done() {
+ throw new Test262Error();
+ }
+ };
+ }
+ }
+ }
+};
+
+assert.throws(Test262Error, () => {
+ var obj = new AggregateError(case11);
+}, 'IteratorCompete abrupts getting the done property');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js
new file mode 100644
index 0000000000..73f8c49fe8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js
@@ -0,0 +1,71 @@
+// 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: >
+ Iteration of errors
+info: |
+ AggregateError ( errors, message )
+
+ ...
+ 3. Let errorsList be ? IterableToList(errors).
+ 4. Set O.[[AggregateErrors]] to errorsList.
+ ...
+ 6. Return O.
+
+ Runtime Semantics: IterableToList ( items [ , method ] )
+
+ 1. If method is present, then
+ ...
+ 2. Else,
+ b. Let iteratorRecord be ? GetIterator(items, sync).
+ 3. Let values be a new empty List.
+ 4. Let next be true.
+ 5. Repeat, while next is not false
+ a. Set next to ? IteratorStep(iteratorRecord).
+ b. If next is not false, then
+ i. Let nextValue be ? IteratorValue(next).
+ ii. Append nextValue to the end of the List values.
+ 6. Return values.
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ 6. Let nextMethod be ? GetV(iterator, "next").
+ ...
+ 8. Return iteratorRecord.
+features: [AggregateError, Symbol.iterator]
+includes: [compareArray.js]
+---*/
+
+var count = 0;
+var values = [];
+var case1 = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ count += 1;
+ return {
+ done: count === 3,
+ get value() {
+ values.push(count)
+ }
+ };
+ }
+ };
+ }
+};
+
+new AggregateError(case1);
+
+assert.sameValue(count, 3);
+assert.compareArray(values, [1, 2]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/is-a-constructor.js
new file mode 100644
index 0000000000..43274be95d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/is-a-constructor.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ The AggregateError constructor implements [[Construct]]
+info: |
+ IsConstructor ( argument )
+
+ The abstract operation IsConstructor takes argument argument (an ECMAScript language value).
+ It determines if argument is a function object with a [[Construct]] internal method.
+ It performs the following steps when called:
+
+ If Type(argument) is not Object, return false.
+ If argument has a [[Construct]] internal method, return true.
+ Return false.
+includes: [isConstructor.js]
+features: [Reflect.construct, AggregateError]
+---*/
+
+assert.sameValue(isConstructor(AggregateError), true, 'isConstructor(AggregateError) must return true');
+new AggregateError([]);
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/length.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/length.js
new file mode 100644
index 0000000000..4de6eedb6b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/length.js
@@ -0,0 +1,34 @@
+// 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: AggregateError.length property descriptor
+info: |
+ AggregateError ( errors, message )
+
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description. Optional parameters
+ (which are indicated with brackets: [ ]) or rest parameters (which
+ are shown using the form «...name») are not included in the default
+ argument count.
+
+ Unless otherwise specified, the length property of a built-in
+ function object has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+verifyProperty(AggregateError, 'length', {
+ value: 2,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop-cast.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop-cast.js
new file mode 100644
index 0000000000..f6b0d78f47
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop-cast.js
@@ -0,0 +1,71 @@
+// 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: >
+ Cast ToString values of message in the created method property
+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.
+
+ CreateMethodProperty ( O, P, V )
+
+ ...
+ 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
+ 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+features: [AggregateError]
+includes: [propertyHelper.js]
+---*/
+
+var case1 = new AggregateError([], 42);
+
+verifyProperty(case1, 'message', {
+ value: '42',
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+var case2 = new AggregateError([], false);
+
+verifyProperty(case2, 'message', {
+ value: 'false',
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+var case3 = new AggregateError([], true);
+
+verifyProperty(case3, 'message', {
+ value: 'true',
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+var case4 = new AggregateError([], { toString() { return 'string'; }});
+
+verifyProperty(case4, 'message', {
+ value: 'string',
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+var case5 = new AggregateError([], null);
+
+verifyProperty(case5, 'message', {
+ value: 'null',
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop.js
new file mode 100644
index 0000000000..ca137c78d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-method-prop.js
@@ -0,0 +1,35 @@
+// 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: >
+ Creates a method property for 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.
+
+ CreateMethodProperty ( O, P, V )
+
+ ...
+ 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
+ 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+features: [AggregateError]
+includes: [propertyHelper.js]
+---*/
+
+var obj = new AggregateError([], '42');
+
+verifyProperty(obj, 'message', {
+ value: '42',
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt-symbol.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt-symbol.js
new file mode 100644
index 0000000000..fff1b0051c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-tostring-abrupt-symbol.js
@@ -0,0 +1,41 @@
+// 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(Symbol 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, Symbol.toPrimitive]
+---*/
+
+var case1 = Symbol();
+
+assert.throws(TypeError, () => {
+ new AggregateError([], case1);
+}, 'toPrimitive');
+
+var case2 = {
+ [Symbol.toPrimitive]() {
+ return Symbol();
+ },
+ toString() {
+ throw new Test262Error();
+ },
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(TypeError, () => {
+ new AggregateError([], case2);
+}, 'from ToPrimitive');
+
+reportCompare(0, 0);
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);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-undefined-no-prop.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-undefined-no-prop.js
new file mode 100644
index 0000000000..80885b45ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/message-undefined-no-prop.js
@@ -0,0 +1,35 @@
+// 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: >
+ If message is undefined, no property will be set to the new instance
+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]
+---*/
+
+var case1 = new AggregateError([], undefined);
+
+assert.sameValue(
+ Object.prototype.hasOwnProperty.call(case1, 'message'),
+ false,
+ 'explicit'
+);
+
+var case2 = new AggregateError([]);
+
+assert.sameValue(
+ Object.prototype.hasOwnProperty.call(case2, 'message'),
+ false,
+ 'implicit'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/name.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/name.js
new file mode 100644
index 0000000000..5120c2097d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/name.js
@@ -0,0 +1,35 @@
+// 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: AggregateError.name property descriptor
+info: |
+ Properties of the AggregateError Constructor
+
+ - has a name property whose value is the String value "AggregateError".
+
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String. Unless otherwise specified, this value is the name that
+ is given to the function in this specification. For functions that
+ are specified as properties of objects, the name value is the
+ property name string used to access the function. [...]
+
+ Unless otherwise specified, the name property of a built-in function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+verifyProperty(AggregateError, 'name', {
+ value: 'AggregateError',
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-is-undefined.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-is-undefined.js
new file mode 100644
index 0000000000..3f02d5509e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-is-undefined.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-aggregate-error
+description: >
+ NewTarget is undefined
+info: |
+ AggregateError ( errors, message )
+
+ 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
+
+features: [AggregateError]
+---*/
+
+var obj = AggregateError([], '');
+
+assert.sameValue(Object.getPrototypeOf(obj), AggregateError.prototype);
+assert(obj instanceof AggregateError);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-custom.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-custom.js
new file mode 100644
index 0000000000..0cf7359a59
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-custom.js
@@ -0,0 +1,49 @@
+// 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: >
+ Use a custom NewTarget prototype
+info: |
+ AggregateError ( errors, message )
+
+ 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
+ 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
+ ...
+ 6. Return O.
+
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
+ Return proto.
+features: [AggregateError, Reflect.construct]
+---*/
+
+var custom = { x: 42 };
+var newt = new Proxy(function() {}, {
+ get(t, p) {
+ if (p === 'prototype') {
+ return custom;
+ }
+
+ return t[p];
+ }
+});
+
+var obj = Reflect.construct(AggregateError, [[]], newt);
+
+assert.sameValue(Object.getPrototypeOf(obj), custom);
+assert.sameValue(obj.x, 42);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-fallback.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-fallback.js
new file mode 100644
index 0000000000..95083d9a47
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-fallback.js
@@ -0,0 +1,60 @@
+// 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: >
+ Fallback to the NewTarget's [[Prototype]] if the prototype property is not an object
+info: |
+ AggregateError ( errors, message )
+
+ 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
+ 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
+ ...
+ 6. Return O.
+
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
+ Return proto.
+features: [AggregateError, Symbol]
+---*/
+
+const values = [
+ undefined,
+ null,
+ 42,
+ false,
+ true,
+ Symbol(),
+ 'string',
+ AggregateError.prototype,
+];
+
+const NewTarget = new Function();
+
+for (const value of values) {
+ const NewTargetProxy = new Proxy(NewTarget, {
+ get(t, p) {
+ if (p === 'prototype') {
+ return value;
+ }
+ return t[p];
+ }
+ });
+
+ const error = Reflect.construct(AggregateError, [[]], NewTargetProxy);
+ assert.sameValue(Object.getPrototypeOf(error), AggregateError.prototype);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto.js
new file mode 100644
index 0000000000..37dcaac082
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto.js
@@ -0,0 +1,37 @@
+// 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: >
+ Default prototype is the %AggregateError.prototype%"
+info: |
+ AggregateError ( errors, message )
+
+ 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
+ 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
+ ...
+ 6. Return O.
+
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
+ Return proto.
+features: [AggregateError]
+---*/
+
+var obj = new AggregateError([]);
+
+assert.sameValue(Object.getPrototypeOf(obj), AggregateError.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/order-of-args-evaluation.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/order-of-args-evaluation.js
new file mode 100644
index 0000000000..18a8b8a0e0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/order-of-args-evaluation.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-aggregate-error
+description: >
+ Process arguments in superclass-then-subclass order
+info: |
+ AggregateError ( errors, message )
+
+ TODO: get updated prose
+
+features: [AggregateError, Symbol.iterator]
+includes: [promiseHelper.js]
+---*/
+
+let sequence = [];
+const message = {
+ toString() {
+ sequence.push(1);
+ return '';
+ }
+};
+const errors = {
+ [Symbol.iterator]() {
+ sequence.push(2);
+ return {
+ next() {
+ sequence.push(3);
+ return {
+ done: true
+ };
+ }
+ };
+ }
+};
+
+new AggregateError(errors, message);
+
+assert.sameValue(sequence.length, 3);
+checkSequence(sequence);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prop-desc.js
new file mode 100644
index 0000000000..ee7790224f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prop-desc.js
@@ -0,0 +1,28 @@
+// 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: >
+ Property descriptor of AggregateError
+info: |
+ The AggregateError Object
+
+ ECMAScript Standard Built-in Objects:
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+assert.sameValue(typeof AggregateError, 'function');
+
+verifyProperty(this, 'AggregateError', {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto-from-ctor-realm.js
new file mode 100644
index 0000000000..5575b8c109
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto-from-ctor-realm.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-aggregate-error
+description: Default [[Prototype]] value derived from realm of the NewTarget.
+info: |
+ AggregateError ( errors, message )
+
+ 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
+ 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
+ ...
+ 6. Return O.
+
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, 'prototype').
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
+ 5. Return proto.
+features: [AggregateError, cross-realm, Reflect, Symbol]
+---*/
+
+var other = $262.createRealm().global;
+var newTarget = new other.Function();
+var err;
+
+newTarget.prototype = undefined;
+err = Reflect.construct(AggregateError, [[]], newTarget);
+assert.sameValue(Object.getPrototypeOf(err), other.AggregateError.prototype, 'newTarget.prototype is undefined');
+
+newTarget.prototype = null;
+err = Reflect.construct(AggregateError, [[]], newTarget);
+assert.sameValue(Object.getPrototypeOf(err), other.AggregateError.prototype, 'newTarget.prototype is null');
+
+newTarget.prototype = true;
+err = Reflect.construct(AggregateError, [[]], newTarget);
+assert.sameValue(Object.getPrototypeOf(err), other.AggregateError.prototype, 'newTarget.prototype is a Boolean');
+
+newTarget.prototype = '';
+err = Reflect.construct(AggregateError, [[]], newTarget);
+assert.sameValue(Object.getPrototypeOf(err), other.AggregateError.prototype, 'newTarget.prototype is a String');
+
+newTarget.prototype = Symbol();
+err = Reflect.construct(AggregateError, [[]], newTarget);
+assert.sameValue(Object.getPrototypeOf(err), other.AggregateError.prototype, 'newTarget.prototype is a Symbol');
+
+newTarget.prototype = -1;
+err = Reflect.construct(AggregateError, [[]], newTarget);
+assert.sameValue(Object.getPrototypeOf(err), other.AggregateError.prototype, 'newTarget.prototype is a Number');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto.js
new file mode 100644
index 0000000000..0149c38054
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/proto.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: The prototype of AggregateError constructor is Error
+esid: sec-aggregate-error
+info: |
+ Properties of the AggregateError Constructor
+
+ - has a [[Prototype]] internal slot whose value is the intrinsic object %Error%.
+features: [AggregateError]
+---*/
+
+var proto = Object.getPrototypeOf(AggregateError);
+
+assert.sameValue(proto, Error);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/browser.js
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/constructor.js
new file mode 100644
index 0000000000..de481f082e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/constructor.js
@@ -0,0 +1,27 @@
+// 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.prototype.constructor
+description: >
+ The `AggregateError.prototype.constructor` property descriptor.
+info: |
+ The initial value of AggregateError.prototype.constructor is the intrinsic
+ object %AggregateError%.
+
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every other data property described (...) has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+verifyProperty(AggregateError.prototype, 'constructor', {
+ value: AggregateError,
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/errors-absent-on-prototype.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/errors-absent-on-prototype.js
new file mode 100644
index 0000000000..b956a12d5f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/errors-absent-on-prototype.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2020 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-the-aggregate-error-prototype-objects
+description: >
+ The AggregateError prototype object isn't an AggregateError instance.
+info: |
+ Properties of the AggregateError Prototype Object
+
+ The AggregateError prototype object:
+ ...
+ - is not an Error instance or an AggregateError instance and does not have an
+ [[ErrorData]] internal slot.
+ ...
+features: [AggregateError]
+---*/
+
+assert.sameValue(AggregateError.prototype.hasOwnProperty("errors"), false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/message.js
new file mode 100644
index 0000000000..c3ed7d98b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/message.js
@@ -0,0 +1,27 @@
+// 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.prototype.message
+description: >
+ The `AggregateError.prototype.message` property descriptor.
+info: |
+ The initial value of the message property of the prototype for a given AggregateError
+ constructor is the empty String.
+
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every other data property described (...) has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+verifyProperty(AggregateError.prototype, 'message', {
+ value: '',
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/name.js
new file mode 100644
index 0000000000..7552a8af35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/name.js
@@ -0,0 +1,26 @@
+// 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.prototype.name
+description: >
+ The `AggregateError.prototype.name` property descriptor.
+info: |
+ The initial value of AggregateError.prototype.name is "AggregateError".
+
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every other data property described (...) has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+verifyProperty(AggregateError.prototype, 'name', {
+ value: 'AggregateError',
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/prop-desc.js
new file mode 100644
index 0000000000..12b998f32c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/prop-desc.js
@@ -0,0 +1,26 @@
+// 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.prototype
+description: >
+ Property descriptor of AggregateError.prototype
+info: |
+ AggregateError.prototype
+
+ The initial value of AggregateError.prototype is the intrinsic object %AggregateErrorPrototype%.
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
+includes: [propertyHelper.js]
+features: [AggregateError]
+---*/
+
+assert.sameValue(typeof AggregateError.prototype, 'object');
+
+verifyProperty(AggregateError, 'prototype', {
+ enumerable: false,
+ writable: false,
+ configurable: false
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/proto.js
new file mode 100644
index 0000000000..a42bab316a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/proto.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-the-aggregate-error-prototype-objects
+description: The prototype of AggregateError.prototype constructor is Error.prototype
+info: |
+ Properties of the AggregateError Prototype Object
+
+ - has a [[Prototype]] internal slot whose value is the intrinsic object %Error.prototype%.
+features: [AggregateError]
+---*/
+
+var proto = Object.getPrototypeOf(AggregateError.prototype);
+
+assert.sameValue(proto, Error.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/prototype/shell.js
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/shell.js
new file mode 100644
index 0000000000..6fbf1a63a4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/shell.js
@@ -0,0 +1,101 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
+
+// file: promiseHelper.js
+// Copyright (C) 2017 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Check that an array contains a numeric sequence starting at 1
+ and incrementing by 1 for each entry in the array. Used by
+ Promise tests to assert the order of execution in deep Promise
+ resolution pipelines.
+defines: [checkSequence, checkSettledPromises]
+---*/
+
+function checkSequence(arr, message) {
+ arr.forEach(function(e, i) {
+ if (e !== (i+1)) {
+ throw new Test262Error((message ? message : "Steps in unexpected sequence:") +
+ " '" + arr.join(',') + "'");
+ }
+ });
+
+ return true;
+}
+
+function checkSettledPromises(settleds, expected, message) {
+ const prefix = message ? `${message}: ` : '';
+
+ assert.sameValue(Array.isArray(settleds), true, `${prefix}Settled values is an array`);
+
+ assert.sameValue(
+ settleds.length,
+ expected.length,
+ `${prefix}The settled values has a different length than expected`
+ );
+
+ settleds.forEach((settled, i) => {
+ assert.sameValue(
+ Object.prototype.hasOwnProperty.call(settled, 'status'),
+ true,
+ `${prefix}The settled value has a property status`
+ );
+
+ assert.sameValue(settled.status, expected[i].status, `${prefix}status for item ${i}`);
+
+ if (settled.status === 'fulfilled') {
+ assert.sameValue(
+ Object.prototype.hasOwnProperty.call(settled, 'value'),
+ true,
+ `${prefix}The fulfilled promise has a property named value`
+ );
+
+ assert.sameValue(
+ Object.prototype.hasOwnProperty.call(settled, 'reason'),
+ false,
+ `${prefix}The fulfilled promise has no property named reason`
+ );
+
+ assert.sameValue(settled.value, expected[i].value, `${prefix}value for item ${i}`);
+ } else {
+ assert.sameValue(settled.status, 'rejected', `${prefix}Valid statuses are only fulfilled or rejected`);
+
+ assert.sameValue(
+ Object.prototype.hasOwnProperty.call(settled, 'value'),
+ false,
+ `${prefix}The fulfilled promise has no property named value`
+ );
+
+ assert.sameValue(
+ Object.prototype.hasOwnProperty.call(settled, 'reason'),
+ true,
+ `${prefix}The fulfilled promise has a property named reason`
+ );
+
+ assert.sameValue(settled.reason, expected[i].reason, `${prefix}Reason value for item ${i}`);
+ }
+ });
+}