diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Error')
54 files changed, 999 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Error/browser.js b/js/src/tests/test262/built-ins/Error/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/browser.js diff --git a/js/src/tests/test262/built-ins/Error/instance-prototype.js b/js/src/tests/test262/built-ins/Error/instance-prototype.js new file mode 100644 index 0000000000..0e66b86a1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/instance-prototype.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype +description: > + The initial value of Error.prototype is the Error prototype object. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Error.prototype.isPrototypeOf(new Error()), true, + 'Error.prototype.isPrototypeOf(new Error()) returns true' +); + +assert.sameValue( + Error.prototype.isPrototypeOf(Error()), true, + 'Error.prototype.isPrototypeOf(Error()) returns true' +); + +verifyNotEnumerable(Error, 'prototype'); +verifyNotWritable(Error, 'prototype'); +verifyNotConfigurable(Error, 'prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/internal-prototype.js b/js/src/tests/test262/built-ins/Error/internal-prototype.js new file mode 100644 index 0000000000..32134b5418 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/internal-prototype.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-error-constructor +description: > + The Error constructor has a [[Prototype]] internal slot whose value is %Function.prototype%. +---*/ + +assert.sameValue( + Function.prototype.isPrototypeOf(Error().constructor), + true, + 'Function.prototype.isPrototypeOf(err1.constructor) returns true' +); + +assert.sameValue( + Function.prototype.isPrototypeOf(Error.constructor), + true, + 'Function.prototype.isPrototypeOf(Error.constructor) returns true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/is-a-constructor.js b/js/src/tests/test262/built-ins/Error/is-a-constructor.js new file mode 100644 index 0000000000..03c9db1fdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/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 Error 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(Error), true, 'isConstructor(Error) must return true'); +new Error(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/length.js b/js/src/tests/test262/built-ins/Error/length.js new file mode 100644 index 0000000000..d442865cfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/length.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property value is 1 +es5id: 15.11.3_A2_T1 +description: Checking length property +---*/ + +var err1 = Error("err"); +assert.sameValue(err1.constructor.length, 1, 'The value of err1.constructor.length is 1'); +assert.sameValue(Error.constructor.length, 1, 'The value of Error.constructor.length is 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/message_property.js b/js/src/tests/test262/built-ins/Error/message_property.js new file mode 100644 index 0000000000..85d9f128cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/message_property.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. + +/*--- +description: Error constructor creates own message property +info: | + 19.5.1.1 Error ( 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.1.1 +includes: [propertyHelper.js] +---*/ + +var message = "my-message"; +var error = new Error(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/Error/name.js b/js/src/tests/test262/built-ins/Error/name.js new file mode 100644 index 0000000000..6deb819766 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/name.js @@ -0,0 +1,13 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype.name +description: > + The initial value of Error.prototype.name is "Error". +---*/ + +assert.sameValue(Error.prototype.name, 'Error'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prop-desc.js b/js/src/tests/test262/built-ins/Error/prop-desc.js new file mode 100644 index 0000000000..b1e4fa9baf --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/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-error +description: Property descriptor for Error +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, "Error"); +verifyWritable(this, "Error"); +verifyConfigurable(this, "Error"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Error/proto-from-ctor-realm.js new file mode 100644 index 0000000000..a1449c9dc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/proto-from-ctor-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-error-message +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%ErrorPrototype%", + « [[ErrorData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Error, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A1_T1.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A1_T1.js new file mode 100644 index 0000000000..a357c97cd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A1_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Error.prototype property has the attributes {DontDelete} +es5id: 15.11.3.1_A1_T1 +description: Checking if deleting the Error.prototype property fails +includes: [propertyHelper.js] +---*/ + +var proto = Error.prototype; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +verifyNotConfigurable(Error, "prototype"); +try { + if ((delete Error.prototype) !== false) { + $ERROR('#1: Error.prototype has the attribute DontDelete'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (Error.prototype !== proto) { + $ERROR('#2: var proto=Error.prototype; delete Error.prototype; Error.prototype===proto. Actual: ' + Error.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A2_T1.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A2_T1.js new file mode 100644 index 0000000000..ccfa526737 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A2_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Error.prototype property has the attributes {DontEnum} +es5id: 15.11.3.1_A2_T1 +description: Checking if enumerating the Error.prototype property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(Error.hasOwnProperty('prototype'))) { + $ERROR('#0: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (Error.propertyIsEnumerable('prototype')) { + $ERROR('#1: Error.propertyIsEnumerable(\'prototype\') return false. Actual: ' + Error.propertyIsEnumerable('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var cout = 0; + +for (var p in Error) { + if (p === "prototype") cout++; +} + +if (cout !== 0) { + $ERROR('#2: cout === 0. Actual: ' + cout); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A3_T1.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A3_T1.js new file mode 100644 index 0000000000..94eca51dd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A3_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Error.prototype property has the attributes {ReadOnly} +es5id: 15.11.3.1_A3_T1 +description: Checking if varying the Error.prototype property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(Error.hasOwnProperty('prototype'))) { + $ERROR('#1: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = Error.prototype; + +verifyNotWritable(Error, "prototype", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (Error.prototype !== __obj) { + $ERROR('#2: __obj = Error.prototype; Error.prototype = function(){return "shifted";}; Error.prototype === __obj. Actual: ' + Error.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try { + Error.prototype(); + $ERROR('#3: "Error.prototype()" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A4_T1.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A4_T1.js new file mode 100644 index 0000000000..a25360c876 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.3.1_A4_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Error has property prototype +es5id: 15.11.3.1_A4_T1 +description: Checking Error.hasOwnProperty('prototype') +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(Error.hasOwnProperty('prototype'))) { + $ERROR('#1: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A1.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A1.js new file mode 100644 index 0000000000..22af7cb662 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the Error prototype object is the Object prototype + object(15.2.3.1) +es5id: 15.11.4_A1 +description: Get Error.prototype and compare with Object.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (!Object.prototype.isPrototypeOf(Error.prototype)) { + $ERROR('#1: Object.prototype.isPrototypeOf(Error.prototype) return true. Actual: ' + Object.prototype.isPrototypeOf(Error.prototype)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A2.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A2.js new file mode 100644 index 0000000000..6e55f4bb67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Class]] property of Error prototype object is + "Object" +es5id: 15.11.4_A2 +description: > + Getting the value of the internal [[Class]] property using + Error.prototype.toString() function +---*/ + +Error.prototype.toString = Object.prototype.toString; +var __tostr = Error.prototype.toString(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__tostr !== "[object Object]") { + $ERROR('#1: Error.prototype.toString=Object.prototype.toString; __tostr = Error.prototype.toString(); __tostr === "[object Object]". Actual: ' + __tostr); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A3.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A3.js new file mode 100644 index 0000000000..6874a0bb67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Since Error prototype object is not function it has no [[Call]] method +es5id: 15.11.4_A3 +description: Checking if call of Error prototype as a function fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + Error.prototype(); + $ERROR('#1: "Error.prototype()" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A4.js b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A4.js new file mode 100644 index 0000000000..33d2451de9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/S15.11.4_A4.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Since Error prototype object is not function it has no [[Construct]] method +es5id: 15.11.4_A4 +description: Checking if creating "new Error.prototype" fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var __instance = new Error.prototype; + $ERROR('#1: "var __instance = new Error.prototype" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/browser.js b/js/src/tests/test262/built-ins/Error/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/constructor/S15.11.4.1_A1_T1.js b/js/src/tests/test262/built-ins/Error/prototype/constructor/S15.11.4.1_A1_T1.js new file mode 100644 index 0000000000..9489b59547 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/constructor/S15.11.4.1_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The initial value of Error.prototype.constructor is the built-in Error + constructor +es5id: 15.11.4.1_A1_T1 +description: Checking Error.prototype.constructor +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (Error.prototype.constructor !== Error) { + $ERROR('#1: Error.prototype.constructor === Error. Actual: ' + Error.prototype.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/constructor/S15.11.4.1_A1_T2.js b/js/src/tests/test262/built-ins/Error/prototype/constructor/S15.11.4.1_A1_T2.js new file mode 100644 index 0000000000..1d449649f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/constructor/S15.11.4.1_A1_T2.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The initial value of Error.prototype.constructor is the built-in Error + constructor +es5id: 15.11.4.1_A1_T2 +description: > + Checking if creating "new Error.prototype.constructor" passes and + checking its properties +---*/ + +var constr = Error.prototype.constructor; + +var err = new constr; + +////////////////////////////////////////////////////////////////////////////// +// CHECK#0 +if (err === undefined) { + $ERROR('#0: constr = Error.prototype.constructor; err = new constr; err === undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (err.constructor !== Error) { + $ERROR('#1: constr = Error.prototype.constructor; err = new constr; err.constructor === Error. Actual: ' + err.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +if (!(Error.prototype.isPrototypeOf(err))) { + $ERROR('#2: constr = Error.prototype.constructor; err = new constr; Error.prototype.isPrototypeOf(err) return true. Actual: ' + Error.prototype.isPrototypeOf(err)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#3 +Error.prototype.toString = Object.prototype.toString; +var to_string_result = '[object ' + 'Error' + ']'; +if (err.toString() !== to_string_result) { + $ERROR('#3: constr = Error.prototype.constructor; err = new constr; Error.prototype.toString=Object.prototype.toString; err.toString() === \'[object Error]\'. Actual: ' + err.toString()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#4 +if (err.valueOf().toString() !== to_string_result) { + $ERROR('#4: constr = Error.prototype.constructor; err = new constr; Error.prototype.toString=Object.prototype.toString; err.valueOf().toString() === \'[object Error]\'. Actual: ' + err.valueOf().toString()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/Error/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/constructor/browser.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/Error/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/constructor/shell.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/message/15.11.4.3-1.js b/js/src/tests/test262/built-ins/Error/prototype/message/15.11.4.3-1.js new file mode 100644 index 0000000000..a08aabdb77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/message/15.11.4.3-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.3-1 +description: Error.prototype.message is not enumerable. +---*/ + +for (var i in Error.prototype) { + assert.notSameValue(i, "message", 'i'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/message/S15.11.4.3_A1.js b/js/src/tests/test262/built-ins/Error/prototype/message/S15.11.4.3_A1.js new file mode 100644 index 0000000000..6399a38e41 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/message/S15.11.4.3_A1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Error.prototype has message property +es5id: 15.11.4.3_A1 +description: Checking Error.prototype.message +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (!Error.prototype.hasOwnProperty('message')) { + $ERROR('#1: Error.prototype.hasOwnProperty(\'message\') reurn true. Actual: ' + Error.prototype.hasOwnProperty('message')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/message/S15.11.4.3_A2.js b/js/src/tests/test262/built-ins/Error/prototype/message/S15.11.4.3_A2.js new file mode 100644 index 0000000000..4416f871cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/message/S15.11.4.3_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The initial value of Error.prototype.message is "" +es5id: 15.11.4.3_A2 +description: Checking value of Error.prototype.message +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (typeof Error.prototype.message !== "string") { + $ERROR('#1: typeof Error.prototype.message === "string". Actual: ' + Error.prototype.message); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/message/browser.js b/js/src/tests/test262/built-ins/Error/prototype/message/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/message/browser.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/message/shell.js b/js/src/tests/test262/built-ins/Error/prototype/message/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/message/shell.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/name/15.11.4.2-1.js b/js/src/tests/test262/built-ins/Error/prototype/name/15.11.4.2-1.js new file mode 100644 index 0000000000..c3f289fb43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/name/15.11.4.2-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.2-1 +description: Error.prototype.name is not enumerable. +---*/ + +for (var i in Error.prototype) { + assert.notSameValue(i, "name", 'i'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/name/S15.11.4.2_A1.js b/js/src/tests/test262/built-ins/Error/prototype/name/S15.11.4.2_A1.js new file mode 100644 index 0000000000..5ef9037f3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/name/S15.11.4.2_A1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Error.prototype has name property +es5id: 15.11.4.2_A1 +description: Checking Error.prototype.name +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (!Error.prototype.hasOwnProperty('name')) { + $ERROR('#1: Error.prototype.hasOwnProperty(\'name\') return true. Actual: ' + Error.prototype.hasOwnProperty('name')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/name/S15.11.4.2_A2.js b/js/src/tests/test262/built-ins/Error/prototype/name/S15.11.4.2_A2.js new file mode 100644 index 0000000000..77dfe53bec --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/name/S15.11.4.2_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The initial value of Error.prototype.name is "Error" +es5id: 15.11.4.2_A2 +description: Checking value of Error.prototype.name +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (Error.prototype.name !== "Error") { + $ERROR('#1: Error.prototype.name==="Error". Actual: ' + Error.prototype.name); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/name/browser.js b/js/src/tests/test262/built-ins/Error/prototype/name/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/name/browser.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/name/shell.js b/js/src/tests/test262/built-ins/Error/prototype/name/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/name/shell.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/no-error-data.js b/js/src/tests/test262/built-ins/Error/prototype/no-error-data.js new file mode 100644 index 0000000000..1856344f09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/no-error-data.js @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-the-error-prototype-object +description: > + The Error Prototype object does not have a [[ErrorData]] internal slot. +info: | + Properties of the Error Prototype Object + + The Error prototype object: + [...] + * is not an Error instance and does not have an [[ErrorData]] internal slot. + + Object.prototype.toString ( ) + + [...] + 8. Else if O has an [[ErrorData]] internal slot, let builtinTag be "Error". + [...] + 15. Let tag be ? Get(O, @@toStringTag). + 16. If Type(tag) is not String, set tag to builtinTag. + 17. Return the string-concatenation of "[object ", tag, and "]". +features: [Symbol.toStringTag] +---*/ + +// Although the spec doesn't define Error.prototype[@@toStringTag], set it +// to non-string anyway because implementations are allowed to define it. +Object.defineProperty(Error.prototype, Symbol.toStringTag, { + value: null, +}); + +assert.sameValue( + Object.prototype.toString.call(Error.prototype), + "[object Object]" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/shell.js b/js/src/tests/test262/built-ins/Error/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-10-1.js b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-10-1.js new file mode 100644 index 0000000000..bbdb716f9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-10-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.4-10-1 +description: > + Error.prototype.toString return the result of concatenating + 'name', ':', a single space character, and 'msg' when 'name' and + 'msg' are non-empty string +---*/ + +var errObj = new Error("ErrorMessage"); +errObj.name = "ErrorName"; + +assert.sameValue(errObj.toString(), "ErrorName: ErrorMessage", 'errObj.toString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-6-1.js b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-6-1.js new file mode 100644 index 0000000000..0e2d855d40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-6-1.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.4-6-1 +description: > + Error.prototype.toString - 'Error' is returned when 'name' is + absent and empty string is returned when 'msg' is undefined +---*/ + +var errObj = new Error(); + +assert.sameValue(errObj.toString(), "Error", 'errObj.toString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-6-2.js b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-6-2.js new file mode 100644 index 0000000000..c766f4137c --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-6-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.4-6-2 +description: > + Error.prototype.toString - 'Error' is returned when 'name' is + absent and value of 'msg' is returned when 'msg' is non-empty + string +---*/ + +var errObj = new Error("ErrorMessage"); + +assert.sameValue(errObj.toString(), "Error: ErrorMessage", 'errObj.toString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-8-1.js b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-8-1.js new file mode 100644 index 0000000000..f3258f40e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-8-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.4-8-1 +description: > + Error.prototype.toString return the value of 'msg' when 'name' is + empty string and 'msg' isn't undefined +---*/ + +var errObj = new Error("ErrorMessage"); +errObj.name = ""; + +assert.sameValue(errObj.toString(), "ErrorMessage", 'errObj.toString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-8-2.js b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-8-2.js new file mode 100644 index 0000000000..1eacdbca62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-8-2.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.4-8-2 +description: > + Error.prototype.toString return empty string when 'name' is empty + string and 'msg' is undefined +---*/ + +var errObj = new Error(); +errObj.name = ""; +if (errObj.name !== "") { + $ERROR("Expected errObj.name to be '', actually " + errObj.name); +} +if (errObj.toString() !== "") { + $ERROR("Expected errObj.toString() to be '', actually " + errObj.toString()); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-9-1.js b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-9-1.js new file mode 100644 index 0000000000..e9bdd17cbf --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/15.11.4.4-9-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.11.4.4-9-1 +description: > + Error.prototype.toString return 'name' when 'name' is non-empty + string and 'msg' is empty string +---*/ + +var errObj = new Error(); +errObj.name = "ErrorName"; + +assert.sameValue(errObj.toString(), "ErrorName", 'errObj.toString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/S15.11.4.4_A1.js b/js/src/tests/test262/built-ins/Error/prototype/toString/S15.11.4.4_A1.js new file mode 100644 index 0000000000..eef4a24f46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/S15.11.4.4_A1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Error.prototype has toString property +es5id: 15.11.4.4_A1 +description: Checking Error.prototype.toString +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (!Error.prototype.hasOwnProperty('toString')) { + $ERROR('#1: Error.prototype.hasOwnProperty(\'toString\') return true. Actual: ' + Error.prototype.hasOwnProperty('toString')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/S15.11.4.4_A2.js b/js/src/tests/test262/built-ins/Error/prototype/toString/S15.11.4.4_A2.js new file mode 100644 index 0000000000..a9d64efd5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/S15.11.4.4_A2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Error.prototype.toString returns an implementation defined string +es5id: 15.11.4.4_A2 +description: Checking if call of Error.prototype.toSting() fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +var err1 = new Error("Error"); +try { + var toStr = err1.toString(); +} +catch (e) { + $ERROR('#1: var err1=new Error("Error"); var toStr=err1.toString(); lead to throwing exception. Exception is ' + e); +} +if (toStr === undefined) { + $ERROR('#2: var err1=new Error("Error"); var toStr=err1.toString(); toStr!==undefined. Actual: ' + toStr); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/browser.js b/js/src/tests/test262/built-ins/Error/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/browser.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/called-as-function.js b/js/src/tests/test262/built-ins/Error/prototype/toString/called-as-function.js new file mode 100644 index 0000000000..7cdb2c025c --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/called-as-function.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype.tostring +description: > + `this` value is resolved using strict mode semantics, + throwing TypeError if called as top-level function. +info: | + Error.prototype.toString ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + + ToObject ( argument ) + + Argument Type: Undefined + Result: Throw a TypeError exception. +---*/ + +["name", "message"].forEach(function(key) { + Object.defineProperty(this, key, { + get: function() { + throw new Test262Error(key + " lookup should not be performed"); + }, + }); +}, this); + +var toString = Error.prototype.toString; +assert.throws(TypeError, function() { + toString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/invalid-receiver.js b/js/src/tests/test262/built-ins/Error/prototype/toString/invalid-receiver.js new file mode 100644 index 0000000000..7855cea62f --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/invalid-receiver.js @@ -0,0 +1,20 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype.tostring +description: > + Error.prototype.toString throws if its receiver is not an object. +info: | + Error.prototype.toString ( ) + 1. Let O be this value. + 2. If Type(O) is not Object, throw a TypeError exception. +---*/ + +[undefined, null, 1, true, 'string', Symbol()].forEach((v) => { + assert.throws(TypeError, () => { + Error.prototype.toString.call(v); + }, `Error.prototype.toString.call(${String(v)})`); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/length.js b/js/src/tests/test262/built-ins/Error/prototype/toString/length.js new file mode 100644 index 0000000000..0f6d033b73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.3.4 +description: > + Error.prototype.toString.length is 0. +info: | + Error.prototype.toString ( ) + + 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(Error.prototype.toString.length, 0); + +verifyNotEnumerable(Error.prototype.toString, "length"); +verifyNotWritable(Error.prototype.toString, "length"); +verifyConfigurable(Error.prototype.toString, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/name.js b/js/src/tests/test262/built-ins/Error/prototype/toString/name.js new file mode 100644 index 0000000000..8896e27dcf --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.3.4 +description: > + Error.prototype.toString.name is "toString". +info: | + Error.prototype.toString ( ) + + 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(Error.prototype.toString.name, "toString"); + +verifyNotEnumerable(Error.prototype.toString, "name"); +verifyNotWritable(Error.prototype.toString, "name"); +verifyConfigurable(Error.prototype.toString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..884c05e62e --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js @@ -0,0 +1,35 @@ +// 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: > + Error.prototype.toString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Error.prototype.toString), + false, + 'isConstructor(Error.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + new Error.prototype.toString(); +}, '`new Error.prototype.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/shell.js b/js/src/tests/test262/built-ins/Error/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/shell.js diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/undefined-props.js b/js/src/tests/test262/built-ins/Error/prototype/toString/undefined-props.js new file mode 100644 index 0000000000..e69ec4c0f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/undefined-props.js @@ -0,0 +1,22 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype.tostring +description: > + Error.prototype.toString handles this.name and this.message being undefined. +info: | + Error.prototype.toString ( ) + ... + 3. Let name be ? Get(O, "name"). + 4. If name is undefined, set name to "Error"; otherwise set name to ? ToString(name). + 5. Let msg be ? Get(O, "message"). + 6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg). +---*/ + +assert.sameValue(Error.prototype.toString.call({}), 'Error'); +assert.sameValue(Error.prototype.toString.call({ message: '42' }), 'Error: 42'); +assert.sameValue(Error.prototype.toString.call({ name: '24' }), '24'); +assert.sameValue(Error.prototype.toString.call({ name: '24', message: '42' }), '24: 42'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/shell.js b/js/src/tests/test262/built-ins/Error/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/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/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.js b/js/src/tests/test262/built-ins/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.js new file mode 100644 index 0000000000..00456c151b --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.js @@ -0,0 +1,15 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype.message +description: The initial value of Error.prototype.message is the empty String. +---*/ + +assert.sameValue(Error('a').message, "a", 'The value of err1.message is "a"'); +assert.sameValue(new Error('a').message, "a", 'The value of err1.message is "a"'); +assert(!Error().hasOwnProperty('message')); +assert(!new Error().hasOwnProperty('message')); +assert.sameValue(new Error().message, Error.prototype.message, 'The value of new Error().message equals Error.prototype.message'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/tostring-1.js b/js/src/tests/test262/built-ins/Error/tostring-1.js new file mode 100644 index 0000000000..5b2279ca44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/tostring-1.js @@ -0,0 +1,15 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.tostring +description: > + Else if O has an [[ErrorData]] internal slot, let builtinTag be "Error". +---*/ +assert.sameValue(new Error().toString(), 'Error', 'new Error.toString() returns "Error"'); + +Error.prototype.toString = Object.prototype.toString; +assert.sameValue(new Error().toString(), '[object Error]', 'new Error.toString() returns "[object Error]" (Object.prototype.toString)'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/tostring-2.js b/js/src/tests/test262/built-ins/Error/tostring-2.js new file mode 100644 index 0000000000..d454717f44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Error/tostring-2.js @@ -0,0 +1,23 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.tostring +description: > + Else if O has an [[ErrorData]] internal slot, let builtinTag be "Error". +---*/ + +assert.sameValue( + Error().toString(), + 'Error', + 'Error().toString() returns "Error"' +); + +Error.prototype.toString = Object.prototype.toString; +assert.sameValue( + Error().toString(), + '[object Error]', + 'Error().toString() returns "[object Error]" (Object.prototype.toString)' +); + +reportCompare(0, 0); |