Coverage: Error message default value + cleanup. Fixes gh-2789

This commit is contained in:
Rick Waldron 2020-09-17 16:14:44 -04:00
parent 5e3761f5c8
commit fd12f5bc6b
16 changed files with 113 additions and 254 deletions

View File

@ -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);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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));
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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());
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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));
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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());
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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));
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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');

View File

@ -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'
);

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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)');

View File

@ -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)'
);