From fd12f5bc6b9b622f0c8a464f5d0623f921419010 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Thu, 17 Sep 2020 16:14:44 -0400 Subject: [PATCH] Coverage: Error message default value + cleanup. Fixes gh-2789 --- test/built-ins/Error/S15.11.1.1_A1_T1.js | 51 ------------------- test/built-ins/Error/S15.11.1.1_A2_T1.js | 19 ------- test/built-ins/Error/S15.11.1.1_A3_T1.js | 20 -------- test/built-ins/Error/S15.11.1_A1_T1.js | 20 -------- test/built-ins/Error/S15.11.2.1_A1_T1.js | 51 ------------------- test/built-ins/Error/S15.11.2.1_A2_T1.js | 19 ------- test/built-ins/Error/S15.11.2.1_A3_T1.js | 20 -------- test/built-ins/Error/S15.11.3_A1_T1.js | 29 ----------- test/built-ins/Error/S15.11.3_A2_T1.js | 25 --------- test/built-ins/Error/instance-prototype.js | 23 +++++++++ test/built-ins/Error/internal-prototype.js | 20 ++++++++ test/built-ins/Error/length.js | 12 +++++ test/built-ins/Error/name.js | 11 ++++ ...rorprototypemessage-is-the-empty-string.js | 13 +++++ test/built-ins/Error/tostring-1.js | 13 +++++ test/built-ins/Error/tostring-2.js | 21 ++++++++ 16 files changed, 113 insertions(+), 254 deletions(-) delete mode 100644 test/built-ins/Error/S15.11.1.1_A1_T1.js delete mode 100644 test/built-ins/Error/S15.11.1.1_A2_T1.js delete mode 100644 test/built-ins/Error/S15.11.1.1_A3_T1.js delete mode 100644 test/built-ins/Error/S15.11.1_A1_T1.js delete mode 100644 test/built-ins/Error/S15.11.2.1_A1_T1.js delete mode 100644 test/built-ins/Error/S15.11.2.1_A2_T1.js delete mode 100644 test/built-ins/Error/S15.11.2.1_A3_T1.js delete mode 100644 test/built-ins/Error/S15.11.3_A1_T1.js delete mode 100644 test/built-ins/Error/S15.11.3_A2_T1.js create mode 100644 test/built-ins/Error/instance-prototype.js create mode 100644 test/built-ins/Error/internal-prototype.js create mode 100644 test/built-ins/Error/length.js create mode 100644 test/built-ins/Error/name.js create mode 100644 test/built-ins/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.js create mode 100644 test/built-ins/Error/tostring-1.js create mode 100644 test/built-ins/Error/tostring-2.js diff --git a/test/built-ins/Error/S15.11.1.1_A1_T1.js b/test/built-ins/Error/S15.11.1.1_A1_T1.js deleted file mode 100644 index a30502f423..0000000000 --- a/test/built-ins/Error/S15.11.1.1_A1_T1.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - If the argument "message" is not undefined, the message property of the newly constructed object is - set to ToString(message) -es5id: 15.11.1.1_A1_T1 -description: Checking message property of different error objects ----*/ - -function otherScope(msg) -{ - return Error(msg); -} - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -var err1 = Error('msg1'); -if (err1.message !== "msg1") { - $ERROR('#1: var err1=Error(\'msg1\'); err1.message==="msg1". Actual: ' + err1.message); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#2 -var err2 = otherScope('msg2'); -if (err2.message !== "msg2") { - $ERROR('#2: function otherScope(msg){return Error(msg);} var err2=otherScope(\'msg2\'); err2.message==="msg2". Actual: ' + err2.message); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#3 -var err3 = otherScope(); -if (err3.hasOwnProperty('message')) { - $ERROR('#3: function otherScope(msg){return Error(msg);} var err3=otherScope(); err3.hasOwnProperty("message"). Actual: ' + err3.message); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#4 -var err4 = eval("Error('msg4')"); -if (err4.message !== "msg4") { - $ERROR('#4: var err4=eval("Error(\'msg4\')"); err4.message==="msg4". Actual: ' + err4.message); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.1.1_A2_T1.js b/test/built-ins/Error/S15.11.1.1_A2_T1.js deleted file mode 100644 index 5e0c1bd836..0000000000 --- a/test/built-ins/Error/S15.11.1.1_A2_T1.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - The [[Prototype]] property of the newly constructed object is set to the original Error prototype - object, the one that is the initial value of Error.prototype (15.11.3.1) -es5id: 15.11.1.1_A2_T1 -description: Checking prototype of the newly constructed Error object ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -var err1 = Error('msg1'); -if (!Error.prototype.isPrototypeOf(err1)) { - $ERROR('#1: var err1=Error(\'msg1\'); Error.prototype.isPrototypeOf(err1) return true. Actual: ' + Error.prototype.isPrototypeOf(err1)); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.1.1_A3_T1.js b/test/built-ins/Error/S15.11.1.1_A3_T1.js deleted file mode 100644 index b6709d8cc0..0000000000 --- a/test/built-ins/Error/S15.11.1.1_A3_T1.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The [[Class]] property of the newly constructed object is set to "Error" -es5id: 15.11.1.1_A3_T1 -description: > - Checking Class of the newly constructed Error object using - toSting() function ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -Error.prototype.toString = Object.prototype.toString; -var err1 = Error(); -if (err1.toString() !== '[object ' + 'Error' + ']') { - $ERROR('#1: Error.prototype.toString=Object.prototype.toString; var err1=Error(); err1.toString()===\'[object Error]\'. Actual: ' + err1.toString()); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.1_A1_T1.js b/test/built-ins/Error/S15.11.1_A1_T1.js deleted file mode 100644 index 5892170d2a..0000000000 --- a/test/built-ins/Error/S15.11.1_A1_T1.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - The function call Error(...) is equivalent to the object creation expression new - Error(...) with the same arguments -es5id: 15.11.1_A1_T1 -description: Checking constructor of the newly constructed Error object ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -Error.prototype.toString = Object.prototype.toString; -var err1 = Error(); -if (err1.constructor !== Error) { - $ERROR('#1: Error.prototype.toString=Object.prototype.toString; var err1=Error(); err1.constructor===Error. Actual: ' + err1.constructor); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.2.1_A1_T1.js b/test/built-ins/Error/S15.11.2.1_A1_T1.js deleted file mode 100644 index 804116b32c..0000000000 --- a/test/built-ins/Error/S15.11.2.1_A1_T1.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - If the argument "message" is not undefined, the message property of the newly constructed object is - set to ToString(message) -es5id: 15.11.2.1_A1_T1 -description: Checking message property of different error objects ----*/ - -function otherScope(msg) -{ - return new Error(msg); -} - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -var err1 = new Error('msg1'); -if (err1.message !== "msg1") { - $ERROR('#1: var err1=new Error(\'msg1\'); err1.message==="msg1". Actual: ' + err1.message); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#2 -var err2 = otherScope('msg2'); -if (err2.message !== "msg2") { - $ERROR('#2: function otherScope(msg){return new Error(msg);} var err2=otherScope(\'msg2\'); err2.message==="msg2". Actual: ' + err2.message); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#3 -var err3 = otherScope(); -if (err3.hasOwnProperty('message')) { - $ERROR('#3: function otherScope(msg){return new Error(msg);} var err3=otherScope(); err3.hasOwnProperty("message"). Actual: ' + err3.message); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#4 -var err4 = eval("new Error('msg4')"); -if (err4.message !== "msg4") { - $ERROR('#4: var err4=eval("new Error(\'msg4\')"); err4.message==="msg4". Actual: ' + err4.message); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.2.1_A2_T1.js b/test/built-ins/Error/S15.11.2.1_A2_T1.js deleted file mode 100644 index 5848bcd4c1..0000000000 --- a/test/built-ins/Error/S15.11.2.1_A2_T1.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - The [[Prototype]] property of the newly constructed object is set to the original Error prototype - object, the one that is the initial value of Error.prototype (15.11.3.1) -es5id: 15.11.2.1_A2_T1 -description: Checking prototype of the newly constructed Error object ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -var err1 = new Error('msg1'); -if (!Error.prototype.isPrototypeOf(err1)) { - $ERROR('#1: Error.prototype.isPrototypeOf(err1) return true. Actual: ' + Error.prototype.isPrototypeOf(err1)); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.2.1_A3_T1.js b/test/built-ins/Error/S15.11.2.1_A3_T1.js deleted file mode 100644 index 4cd39953a4..0000000000 --- a/test/built-ins/Error/S15.11.2.1_A3_T1.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The [[Class]] property of the newly constructed object is set to "Error" -es5id: 15.11.2.1_A3_T1 -description: > - Checking Class of the newly constructed Error object using - toSting() function ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -Error.prototype.toString = Object.prototype.toString; -var err1 = new Error(); -if (err1.toString() !== '[object ' + 'Error' + ']') { - $ERROR('#1: err1.toString()===\'[object Error]\'. Actual: ' + err1.toString()); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.3_A1_T1.js b/test/built-ins/Error/S15.11.3_A1_T1.js deleted file mode 100644 index c0074b6a86..0000000000 --- a/test/built-ins/Error/S15.11.3_A1_T1.js +++ /dev/null @@ -1,29 +0,0 @@ -// 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 constructor - is the Function prototype object(15.3.4) -es5id: 15.11.3_A1_T1 -description: > - Checking prototype of constructor of the newly constructed Error - object ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -var err1 = Error("err"); -if (!Function.prototype.isPrototypeOf(err1.constructor)) { - $ERROR('#1: var err1=Error("err"); Function.prototype.isPrototypeOf(err1.constructor) return true. Actual:' + Function.prototype.isPrototypeOf(err1.constructor)); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#2 -if (!Function.prototype.isPrototypeOf(Error.constructor)) { - $ERROR('#2: Function.prototype.isPrototypeOf(Error.constructor) return true. Actual:' + Function.prototype.isPrototypeOf(Error.constructor)); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/S15.11.3_A2_T1.js b/test/built-ins/Error/S15.11.3_A2_T1.js deleted file mode 100644 index 6cf25327a8..0000000000 --- a/test/built-ins/Error/S15.11.3_A2_T1.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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 ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -var err1 = Error("err"); -if (err1.constructor.length !== 1) { - $ERROR('#1: var err1=Error("err"); err1.constructor.length===1. Actual: ' + err1.constructor.length); -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#2 -if (Error.constructor.length !== 1) { - $ERROR('#2: Error.constructor.length===1. Actual: ' + Error.constructor.length); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/Error/instance-prototype.js b/test/built-ins/Error/instance-prototype.js new file mode 100644 index 0000000000..07bd505805 --- /dev/null +++ b/test/built-ins/Error/instance-prototype.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-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'); diff --git a/test/built-ins/Error/internal-prototype.js b/test/built-ins/Error/internal-prototype.js new file mode 100644 index 0000000000..0bad7eeada --- /dev/null +++ b/test/built-ins/Error/internal-prototype.js @@ -0,0 +1,20 @@ +// 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' +); diff --git a/test/built-ins/Error/length.js b/test/built-ins/Error/length.js new file mode 100644 index 0000000000..7bfb9671ca --- /dev/null +++ b/test/built-ins/Error/length.js @@ -0,0 +1,12 @@ +// 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'); diff --git a/test/built-ins/Error/name.js b/test/built-ins/Error/name.js new file mode 100644 index 0000000000..0020034681 --- /dev/null +++ b/test/built-ins/Error/name.js @@ -0,0 +1,11 @@ +// 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'); + diff --git a/test/built-ins/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.js b/test/built-ins/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.js new file mode 100644 index 0000000000..d47a0e0e6c --- /dev/null +++ b/test/built-ins/Error/the-initial-value-of-errorprototypemessage-is-the-empty-string.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.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'); diff --git a/test/built-ins/Error/tostring-1.js b/test/built-ins/Error/tostring-1.js new file mode 100644 index 0000000000..9108677a0a --- /dev/null +++ b/test/built-ins/Error/tostring-1.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-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)'); + diff --git a/test/built-ins/Error/tostring-2.js b/test/built-ins/Error/tostring-2.js new file mode 100644 index 0000000000..8cf072adca --- /dev/null +++ b/test/built-ins/Error/tostring-2.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-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)' +);