diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/NativeErrors')
145 files changed, 3393 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/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..906392720a --- /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] +---*/ + +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..3935b7096a --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/shell.js @@ -0,0 +1,96 @@ +// 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] +---*/ + +function isConstructor(f) { + 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)) { + $ERROR((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}`); + } + }); +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/constructor.js new file mode 100644 index 0000000000..63982fbbdc --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + EvalError is a constructor function. +---*/ + +assert.sameValue(typeof EvalError, 'function', 'typeof EvalError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/instance-proto.js new file mode 100644 index 0000000000..a80dd0969d --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of EvalError instances is EvalError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new EvalError), EvalError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/is-a-constructor.js new file mode 100644 index 0000000000..220b4c402a --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/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 EvalError 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] +---*/ + +assert.sameValue(isConstructor(EvalError), true, 'isConstructor(EvalError) must return true'); +new EvalError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/is-error-object.js new file mode 100644 index 0000000000..7ef2e95a20 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + EvalError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new EvalError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js new file mode 100644 index 0000000000..4e6a6863d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + EvalError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 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, including optional + parameters. However, rest parameters 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] +---*/ + +assert.sameValue(EvalError.length, 1); + +verifyNotEnumerable(EvalError, "length"); +verifyNotWritable(EvalError, "length"); +verifyConfigurable(EvalError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js new file mode 100644 index 0000000000..d36e58bf73 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + EvalError.name is "EvalError". +info: | + 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, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(EvalError.name, "EvalError"); + +verifyNotEnumerable(EvalError, "name"); +verifyNotWritable(EvalError, "name"); +verifyConfigurable(EvalError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prop-desc.js new file mode 100644 index 0000000000..a99e12e85f --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-evalerror +description: Property descriptor for EvalError +info: | + 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] +---*/ + +verifyNotEnumerable(this, "EvalError"); +verifyWritable(this, "EvalError"); +verifyConfigurable(this, "EvalError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..32c2e07662 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. 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: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(EvalError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.EvalError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(EvalError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.EvalError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = false; +err = Reflect.construct(EvalError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.EvalError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = 'str'; +err = Reflect.construct(EvalError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.EvalError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(EvalError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.EvalError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 0; +err = Reflect.construct(EvalError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.EvalError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/proto.js new file mode 100644 index 0000000000..b69b49a427 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of EvalError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(EvalError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype.js new file mode 100644 index 0000000000..6e43253450 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of EvalError.prototype is the EvalError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(EvalError.prototype, Object.getPrototypeOf(new EvalError)); + +verifyNotEnumerable(EvalError, "prototype"); +verifyNotWritable(EvalError, "prototype"); +verifyNotConfigurable(EvalError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/constructor.js new file mode 100644 index 0000000000..e823b636ec --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of EvalError.prototype.constructor is the EvalError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 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] +---*/ + +assert.sameValue(EvalError.prototype.constructor, EvalError); + +verifyNotEnumerable(EvalError.prototype, "constructor"); +verifyWritable(EvalError.prototype, "constructor"); +verifyConfigurable(EvalError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/message.js new file mode 100644 index 0000000000..bb327493bf --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of EvalError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 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] +---*/ + +assert.sameValue(EvalError.prototype.message, ""); + +verifyNotEnumerable(EvalError.prototype, "message"); +verifyWritable(EvalError.prototype, "message"); +verifyConfigurable(EvalError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js new file mode 100644 index 0000000000..7075febda1 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of EvalError.prototype.name is "EvalError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 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] +---*/ + +assert.sameValue(EvalError.prototype.name, "EvalError"); + +verifyNotEnumerable(EvalError.prototype, "name"); +verifyWritable(EvalError.prototype, "name"); +verifyConfigurable(EvalError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/not-error-object.js new file mode 100644 index 0000000000..58e24d010b --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + EvalError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(EvalError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/proto.js new file mode 100644 index 0000000000..a0d8f20d31 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of EvalError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(EvalError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/constructor.js new file mode 100644 index 0000000000..65264f8206 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + RangeError is a constructor function. +---*/ + +assert.sameValue(typeof RangeError, 'function', 'typeof RangeError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/instance-proto.js new file mode 100644 index 0000000000..dd3649c36d --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of RangeError instances is RangeError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new RangeError), RangeError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/is-a-constructor.js new file mode 100644 index 0000000000..2c35812000 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/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 RangeError 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] +---*/ + +assert.sameValue(isConstructor(RangeError), true, 'isConstructor(RangeError) must return true'); +new RangeError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/is-error-object.js new file mode 100644 index 0000000000..1d84ea9ab5 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + RangeError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new RangeError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js new file mode 100644 index 0000000000..ce9f6d7f13 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + RangeError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 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, including optional + parameters. However, rest parameters 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] +---*/ + +assert.sameValue(RangeError.length, 1); + +verifyNotEnumerable(RangeError, "length"); +verifyNotWritable(RangeError, "length"); +verifyConfigurable(RangeError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js new file mode 100644 index 0000000000..621b07684c --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + RangeError.name is "RangeError". +info: | + 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, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(RangeError.name, "RangeError"); + +verifyNotEnumerable(RangeError, "name"); +verifyNotWritable(RangeError, "name"); +verifyConfigurable(RangeError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prop-desc.js new file mode 100644 index 0000000000..d33c7e1926 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-rangeerror +description: Property descriptor for RangeError +info: | + 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] +---*/ + +verifyNotEnumerable(this, "RangeError"); +verifyWritable(this, "RangeError"); +verifyConfigurable(this, "RangeError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..39067464e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. 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: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(RangeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.RangeError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(RangeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.RangeError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +err = Reflect.construct(RangeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.RangeError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +err = Reflect.construct(RangeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.RangeError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(RangeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.RangeError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = -0; +err = Reflect.construct(RangeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.RangeError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/proto.js new file mode 100644 index 0000000000..5f73711405 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of RangeError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(RangeError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype.js new file mode 100644 index 0000000000..f7c6586270 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of RangeError.prototype is the RangeError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(RangeError.prototype, Object.getPrototypeOf(new RangeError)); + +verifyNotEnumerable(RangeError, "prototype"); +verifyNotWritable(RangeError, "prototype"); +verifyNotConfigurable(RangeError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/constructor.js new file mode 100644 index 0000000000..9a8a5c26e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of RangeError.prototype.constructor is the RangeError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 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] +---*/ + +assert.sameValue(RangeError.prototype.constructor, RangeError); + +verifyNotEnumerable(RangeError.prototype, "constructor"); +verifyWritable(RangeError.prototype, "constructor"); +verifyConfigurable(RangeError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/message.js new file mode 100644 index 0000000000..3de63869c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of RangeError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 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] +---*/ + +assert.sameValue(RangeError.prototype.message, ""); + +verifyNotEnumerable(RangeError.prototype, "message"); +verifyWritable(RangeError.prototype, "message"); +verifyConfigurable(RangeError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js new file mode 100644 index 0000000000..24d76f4949 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of RangeError.prototype.name is "RangeError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 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] +---*/ + +assert.sameValue(RangeError.prototype.name, "RangeError"); + +verifyNotEnumerable(RangeError.prototype, "name"); +verifyWritable(RangeError.prototype, "name"); +verifyConfigurable(RangeError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/not-error-object.js new file mode 100644 index 0000000000..e3ce995446 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + RangeError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(RangeError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/proto.js new file mode 100644 index 0000000000..104dfaf777 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of RangeError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(RangeError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/constructor.js new file mode 100644 index 0000000000..ba287131bf --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + ReferenceError is a constructor function. +---*/ + +assert.sameValue(typeof ReferenceError, 'function', 'typeof ReferenceError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/instance-proto.js new file mode 100644 index 0000000000..97944c7113 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of ReferenceError instances is ReferenceError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new ReferenceError), ReferenceError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-a-constructor.js new file mode 100644 index 0000000000..93c39185e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/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 ReferenceError 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] +---*/ + +assert.sameValue(isConstructor(ReferenceError), true, 'isConstructor(ReferenceError) must return true'); +new ReferenceError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-error-object.js new file mode 100644 index 0000000000..870bb53320 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + ReferenceError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new ReferenceError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js new file mode 100644 index 0000000000..5a3f07d497 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + ReferenceError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 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, including optional + parameters. However, rest parameters 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] +---*/ + +assert.sameValue(ReferenceError.length, 1); + +verifyNotEnumerable(ReferenceError, "length"); +verifyNotWritable(ReferenceError, "length"); +verifyConfigurable(ReferenceError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js new file mode 100644 index 0000000000..66b0a39351 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + ReferenceError.name is "ReferenceError". +info: | + 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, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.name, "ReferenceError"); + +verifyNotEnumerable(ReferenceError, "name"); +verifyNotWritable(ReferenceError, "name"); +verifyConfigurable(ReferenceError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prop-desc.js new file mode 100644 index 0000000000..49cb1ece2d --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-referenceerror +description: Property descriptor for ReferenceError +info: | + 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] +---*/ + +verifyNotEnumerable(this, "ReferenceError"); +verifyWritable(this, "ReferenceError"); +verifyConfigurable(this, "ReferenceError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..b86ad24a54 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. 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: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = false; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = 'str'; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = NaN; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto.js new file mode 100644 index 0000000000..73e8f12c71 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of ReferenceError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(ReferenceError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype.js new file mode 100644 index 0000000000..3031815ead --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of ReferenceError.prototype is the ReferenceError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.prototype, Object.getPrototypeOf(new ReferenceError)); + +verifyNotEnumerable(ReferenceError, "prototype"); +verifyNotWritable(ReferenceError, "prototype"); +verifyNotConfigurable(ReferenceError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/constructor.js new file mode 100644 index 0000000000..891c36eb67 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of ReferenceError.prototype.constructor is the ReferenceError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 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] +---*/ + +assert.sameValue(ReferenceError.prototype.constructor, ReferenceError); + +verifyNotEnumerable(ReferenceError.prototype, "constructor"); +verifyWritable(ReferenceError.prototype, "constructor"); +verifyConfigurable(ReferenceError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/message.js new file mode 100644 index 0000000000..e498b5c85f --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of ReferenceError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 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] +---*/ + +assert.sameValue(ReferenceError.prototype.message, ""); + +verifyNotEnumerable(ReferenceError.prototype, "message"); +verifyWritable(ReferenceError.prototype, "message"); +verifyConfigurable(ReferenceError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js new file mode 100644 index 0000000000..563ec73485 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of ReferenceError.prototype.name is "ReferenceError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 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] +---*/ + +assert.sameValue(ReferenceError.prototype.name, "ReferenceError"); + +verifyNotEnumerable(ReferenceError.prototype, "name"); +verifyWritable(ReferenceError.prototype, "name"); +verifyConfigurable(ReferenceError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/not-error-object.js new file mode 100644 index 0000000000..aaf9ab6748 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + ReferenceError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(ReferenceError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/proto.js new file mode 100644 index 0000000000..c702ff1fa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of ReferenceError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(ReferenceError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/constructor.js new file mode 100644 index 0000000000..79b5fb8708 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + SyntaxError is a constructor function. +---*/ + +assert.sameValue(typeof SyntaxError, 'function', 'typeof SyntaxError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/instance-proto.js new file mode 100644 index 0000000000..792fb96005 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of SyntaxError instances is SyntaxError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new SyntaxError), SyntaxError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-a-constructor.js new file mode 100644 index 0000000000..ad74f340ca --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/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 SyntaxError 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] +---*/ + +assert.sameValue(isConstructor(SyntaxError), true, 'isConstructor(SyntaxError) must return true'); +new SyntaxError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-error-object.js new file mode 100644 index 0000000000..8ea07870fa --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + SyntaxError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new SyntaxError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js new file mode 100644 index 0000000000..555a5c1529 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + SyntaxError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 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, including optional + parameters. However, rest parameters 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] +---*/ + +assert.sameValue(SyntaxError.length, 1); + +verifyNotEnumerable(SyntaxError, "length"); +verifyNotWritable(SyntaxError, "length"); +verifyConfigurable(SyntaxError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js new file mode 100644 index 0000000000..f70899d0fc --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + SyntaxError.name is "SyntaxError". +info: | + 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, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.name, "SyntaxError"); + +verifyNotEnumerable(SyntaxError, "name"); +verifyNotWritable(SyntaxError, "name"); +verifyConfigurable(SyntaxError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prop-desc.js new file mode 100644 index 0000000000..09fad3baa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-syntaxerror +description: Property descriptor for SyntaxError +info: | + 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] +---*/ + +verifyNotEnumerable(this, "SyntaxError"); +verifyWritable(this, "SyntaxError"); +verifyConfigurable(this, "SyntaxError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..7bb0aef336 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. 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: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = Infinity; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto.js new file mode 100644 index 0000000000..119a24e25b --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of SyntaxError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(SyntaxError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype.js new file mode 100644 index 0000000000..2afe909c57 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of SyntaxError.prototype is the SyntaxError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.prototype, Object.getPrototypeOf(new SyntaxError)); + +verifyNotEnumerable(SyntaxError, "prototype"); +verifyNotWritable(SyntaxError, "prototype"); +verifyNotConfigurable(SyntaxError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/constructor.js new file mode 100644 index 0000000000..a5aaf689d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of SyntaxError.prototype.constructor is the SyntaxError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 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] +---*/ + +assert.sameValue(SyntaxError.prototype.constructor, SyntaxError); + +verifyNotEnumerable(SyntaxError.prototype, "constructor"); +verifyWritable(SyntaxError.prototype, "constructor"); +verifyConfigurable(SyntaxError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/message.js new file mode 100644 index 0000000000..43c0f97bad --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of SyntaxError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 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] +---*/ + +assert.sameValue(SyntaxError.prototype.message, ""); + +verifyNotEnumerable(SyntaxError.prototype, "message"); +verifyWritable(SyntaxError.prototype, "message"); +verifyConfigurable(SyntaxError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js new file mode 100644 index 0000000000..8f80d797ba --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of SyntaxError.prototype.name is "SyntaxError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 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] +---*/ + +assert.sameValue(SyntaxError.prototype.name, "SyntaxError"); + +verifyNotEnumerable(SyntaxError.prototype, "name"); +verifyWritable(SyntaxError.prototype, "name"); +verifyConfigurable(SyntaxError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/not-error-object.js new file mode 100644 index 0000000000..4d863890e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + SyntaxError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(SyntaxError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/proto.js new file mode 100644 index 0000000000..4130132fc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of SyntaxError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(SyntaxError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/constructor.js new file mode 100644 index 0000000000..3f4603d970 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + TypeError is a constructor function. +---*/ + +assert.sameValue(typeof TypeError, 'function', 'typeof TypeError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/instance-proto.js new file mode 100644 index 0000000000..10f699888a --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of TypeError instances is TypeError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new TypeError), TypeError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/is-a-constructor.js new file mode 100644 index 0000000000..72c2f9f73c --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/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 TypeError 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] +---*/ + +assert.sameValue(isConstructor(TypeError), true, 'isConstructor(TypeError) must return true'); +new TypeError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/is-error-object.js new file mode 100644 index 0000000000..96e2fb1260 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + TypeError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new TypeError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js new file mode 100644 index 0000000000..c84b02708e --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + TypeError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 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, including optional + parameters. However, rest parameters 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] +---*/ + +assert.sameValue(TypeError.length, 1); + +verifyNotEnumerable(TypeError, "length"); +verifyNotWritable(TypeError, "length"); +verifyConfigurable(TypeError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js new file mode 100644 index 0000000000..ede2f73af9 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + TypeError.name is "TypeError". +info: | + 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, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(TypeError.name, "TypeError"); + +verifyNotEnumerable(TypeError, "name"); +verifyNotWritable(TypeError, "name"); +verifyConfigurable(TypeError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prop-desc.js new file mode 100644 index 0000000000..955b44c17f --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-typeerror +description: Property descriptor for TypeError +info: | + 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] +---*/ + +verifyNotEnumerable(this, "TypeError"); +verifyWritable(this, "TypeError"); +verifyConfigurable(this, "TypeError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..c6b6c8acf0 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. 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: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(TypeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.TypeError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(TypeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.TypeError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = false; +err = Reflect.construct(TypeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.TypeError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = 'str'; +err = Reflect.construct(TypeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.TypeError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(TypeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.TypeError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = -Infinity; +err = Reflect.construct(TypeError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.TypeError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/proto.js new file mode 100644 index 0000000000..192be080e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of TypeError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(TypeError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype.js new file mode 100644 index 0000000000..873b1bcf5e --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of TypeError.prototype is the TypeError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(TypeError.prototype, Object.getPrototypeOf(new TypeError)); + +verifyNotEnumerable(TypeError, "prototype"); +verifyNotWritable(TypeError, "prototype"); +verifyNotConfigurable(TypeError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/constructor.js new file mode 100644 index 0000000000..1424da264a --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of TypeError.prototype.constructor is the TypeError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 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] +---*/ + +assert.sameValue(TypeError.prototype.constructor, TypeError); + +verifyNotEnumerable(TypeError.prototype, "constructor"); +verifyWritable(TypeError.prototype, "constructor"); +verifyConfigurable(TypeError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/message.js new file mode 100644 index 0000000000..ddc410f691 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of TypeError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 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] +---*/ + +assert.sameValue(TypeError.prototype.message, ""); + +verifyNotEnumerable(TypeError.prototype, "message"); +verifyWritable(TypeError.prototype, "message"); +verifyConfigurable(TypeError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js new file mode 100644 index 0000000000..c0c0531ff2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of TypeError.prototype.name is "TypeError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 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] +---*/ + +assert.sameValue(TypeError.prototype.name, "TypeError"); + +verifyNotEnumerable(TypeError.prototype, "name"); +verifyWritable(TypeError.prototype, "name"); +verifyConfigurable(TypeError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/not-error-object.js new file mode 100644 index 0000000000..7cca2dc1e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + TypeError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(TypeError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/proto.js new file mode 100644 index 0000000000..144da3600c --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of TypeError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(TypeError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/constructor.js new file mode 100644 index 0000000000..e931f1c86f --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + URIError is a constructor function. +---*/ + +assert.sameValue(typeof URIError, 'function', 'typeof URIError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/instance-proto.js new file mode 100644 index 0000000000..49d173a062 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of URIError instances is URIError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new URIError), URIError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/is-a-constructor.js new file mode 100644 index 0000000000..35b4a17cdb --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/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 URIError 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] +---*/ + +assert.sameValue(isConstructor(URIError), true, 'isConstructor(URIError) must return true'); +new URIError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/is-error-object.js new file mode 100644 index 0000000000..d37a8e88e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + URIError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new URIError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js new file mode 100644 index 0000000000..5f645e5ecd --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + URIError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 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, including optional + parameters. However, rest parameters 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] +---*/ + +assert.sameValue(URIError.length, 1); + +verifyNotEnumerable(URIError, "length"); +verifyNotWritable(URIError, "length"); +verifyConfigurable(URIError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js new file mode 100644 index 0000000000..ef912a466b --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + URIError.name is "URIError". +info: | + 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, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(URIError.name, "URIError"); + +verifyNotEnumerable(URIError, "name"); +verifyNotWritable(URIError, "name"); +verifyConfigurable(URIError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prop-desc.js new file mode 100644 index 0000000000..bb5ad97bce --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-urierror +description: Property descriptor for URIError +info: | + 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] +---*/ + +verifyNotEnumerable(this, "URIError"); +verifyWritable(this, "URIError"); +verifyConfigurable(this, "URIError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..c99c008a1e --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. 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: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(URIError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.URIError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(URIError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.URIError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +err = Reflect.construct(URIError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.URIError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +err = Reflect.construct(URIError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.URIError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(URIError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.URIError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 0; +err = Reflect.construct(URIError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.URIError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/proto.js new file mode 100644 index 0000000000..7fd4f74bf0 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of URIError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(URIError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype.js new file mode 100644 index 0000000000..a1eb0c7dcb --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of URIError.prototype is the URIError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(URIError.prototype, Object.getPrototypeOf(new URIError)); + +verifyNotEnumerable(URIError, "prototype"); +verifyNotWritable(URIError, "prototype"); +verifyNotConfigurable(URIError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/constructor.js new file mode 100644 index 0000000000..94d37cc64e --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of URIError.prototype.constructor is the URIError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 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] +---*/ + +assert.sameValue(URIError.prototype.constructor, URIError); + +verifyNotEnumerable(URIError.prototype, "constructor"); +verifyWritable(URIError.prototype, "constructor"); +verifyConfigurable(URIError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/message.js new file mode 100644 index 0000000000..58eb18e66f --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of URIError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 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] +---*/ + +assert.sameValue(URIError.prototype.message, ""); + +verifyNotEnumerable(URIError.prototype, "message"); +verifyWritable(URIError.prototype, "message"); +verifyConfigurable(URIError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js new file mode 100644 index 0000000000..3a8b5a369e --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of URIError.prototype.name is "URIError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 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] +---*/ + +assert.sameValue(URIError.prototype.name, "URIError"); + +verifyNotEnumerable(URIError.prototype, "name"); +verifyWritable(URIError.prototype, "name"); +verifyConfigurable(URIError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/not-error-object.js new file mode 100644 index 0000000000..abcbfa6f01 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + URIError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(URIError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/proto.js new file mode 100644 index 0000000000..35a68affd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of URIError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(URIError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/NativeErrors/browser.js b/js/src/tests/test262/built-ins/NativeErrors/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/message_property_native_error.js b/js/src/tests/test262/built-ins/NativeErrors/message_property_native_error.js new file mode 100644 index 0000000000..8759245e84 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/message_property_native_error.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: NativeError constructor creates own message property +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. + ... + c. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}. + d. Let status be DefinePropertyOrThrow(O, "message", msgDesc). +es6id: 19.5.6.1.1 +includes: [propertyHelper.js] +---*/ + +var nativeErrors = [ + EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError +]; + +for (var i = 0; i < nativeErrors.length; ++i) { + var nativeError = nativeErrors[i]; + + var message = "my-message"; + var error = new nativeError(message); + + verifyEqualTo(error, "message", message); + verifyNotEnumerable(error, "message"); + verifyWritable(error, "message"); + verifyConfigurable(error, "message"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/shell.js b/js/src/tests/test262/built-ins/NativeErrors/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/shell.js |