Fix tautological pattern in tests

In neglecting to assert the type of error thrown (or that any error was
thrown at all), these tests cannot fail. Refactor the tests to use the
`assert.throws` helper method, which takes these details into
consideration.
This commit is contained in:
Mike Pennisi 2015-06-16 12:35:27 -04:00
parent e4aac334b8
commit 57f3466cf7
15 changed files with 47 additions and 120 deletions

View File

@ -7,15 +7,8 @@ info: >
[[Construct]] property [[Construct]] property
es5id: 15.3.4_A5 es5id: 15.3.4_A5
description: Checking if creating "new Function.prototype object" fails description: Checking if creating "new Function.prototype object" fails
includes:
- $PRINT.js
---*/ ---*/
//CHECK# assert.throws(TypeError, function() {
try { new Function.prototype;
var obj = new Function.prototype; });
$ERROR('#1: The Function prototype object is itself a Function object without [[Construct]] property: '+e);
} catch (e) {
$PRINT("#1.1: The Function prototype object is itself a Function object without [[Construct]] property "+e);
}

View File

@ -5,15 +5,10 @@
info: Function.prototype.toString can't be used as constructor info: Function.prototype.toString can't be used as constructor
es5id: 15.3.4.2_A7 es5id: 15.3.4.2_A7
description: Checking if creating "new Function.prototype.toString" fails description: Checking if creating "new Function.prototype.toString" fails
includes:
- $PRINT.js
---*/ ---*/
var FACTORY = Function.prototype.toString; var FACTORY = Function.prototype.toString;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Function.prototype.toString can\'t be used as constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -7,14 +7,8 @@ info: >
method method
es5id: 15.2.4_A3 es5id: 15.2.4_A3
description: Checking if calling Object prototype as a function fails description: Checking if calling Object prototype as a function fails
includes:
- $PRINT.js
---*/ ---*/
//CHECK#1 assert.throws(TypeError, function() {
try {
Object.prototype(); Object.prototype();
$ERROR('#1: Since Object prototype object is not function it has not [[call]] method'); });
} catch (e) {
$PRINT(e);
}

View File

@ -7,14 +7,8 @@ info: >
[[create]] method [[create]] method
es5id: 15.2.4_A4 es5id: 15.2.4_A4
description: Checking if creating "new Object.prototype" fails description: Checking if creating "new Object.prototype" fails
includes:
- $PRINT.js
---*/ ---*/
//CHECK#1 assert.throws(TypeError, function() {
try { new Object.prototype;
var instance = new Object.prototype; });
$ERROR('#1: Since Object prototype object is not function it has not [[create]] method');
} catch (e) {
$PRINT(e);
}

View File

@ -11,10 +11,6 @@ includes:
var FACTORY = Object.prototype.hasOwnProperty; var FACTORY = Object.prototype.hasOwnProperty;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Object.prototype.hasOwnProperty can\'t be used as a constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -5,16 +5,10 @@
info: Object.prototype.isPrototypeOf can't be used as a constructor info: Object.prototype.isPrototypeOf can't be used as a constructor
es5id: 15.2.4.6_A7 es5id: 15.2.4.6_A7
description: Checking if creating new "Object.prototype.isPrototypeOf" fails description: Checking if creating new "Object.prototype.isPrototypeOf" fails
includes:
- $PRINT.js
---*/ ---*/
var FACTORY = Object.prototype.isPrototypeOf; var FACTORY = Object.prototype.isPrototypeOf;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Object.prototype.isPrototypeOf can\'t be used as a constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -7,16 +7,10 @@ es5id: 15.2.4.7_A7
description: > description: >
Checking if creating "new Object.prototype.propertyIsEnumerable" Checking if creating "new Object.prototype.propertyIsEnumerable"
fails fails
includes:
- $PRINT.js
---*/ ---*/
var FACTORY = Object.prototype.propertyIsEnumerable; var FACTORY = Object.prototype.propertyIsEnumerable;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Object.prototype.propertyIsEnumerable can\'t be used as a constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -5,16 +5,10 @@
info: Object.prototype.toLocaleString can't be used as a constructor info: Object.prototype.toLocaleString can't be used as a constructor
es5id: 15.2.4.3_A7 es5id: 15.2.4.3_A7
description: Checking if creating "new Object.prototype.toLocaleString" fails description: Checking if creating "new Object.prototype.toLocaleString" fails
includes:
- $PRINT.js
---*/ ---*/
var FACTORY = Object.prototype.toLocaleString; var FACTORY = Object.prototype.toLocaleString;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Object.prototype.toLocaleString can\'t be used as a constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -5,15 +5,10 @@
info: Object.prototype.toString can't be used as a constructor info: Object.prototype.toString can't be used as a constructor
es5id: 15.2.4.2_A7 es5id: 15.2.4.2_A7
description: Checking if creating "new Object.prototype.toString" fails description: Checking if creating "new Object.prototype.toString" fails
includes:
- $PRINT.js
---*/ ---*/
var FACTORY = Object.prototype.toString; var FACTORY = Object.prototype.toString;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Object.prototype.toString can\'t be used as a constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -11,10 +11,6 @@ includes:
var FACTORY = Object.prototype.valueOf; var FACTORY = Object.prototype.valueOf;
try { assert.throws(TypeError, function() {
var instance = new FACTORY; new FACTORY;
$ERROR('#1: Object.prototype.valueOf can\'t be used as a constructor'); });
} catch (e) {
$PRINT(e);
}

View File

@ -5,15 +5,10 @@
info: String.prototype.lastIndexOf can't be used as constructor info: String.prototype.lastIndexOf can't be used as constructor
es5id: 15.5.4.8_A7 es5id: 15.5.4.8_A7
description: Checking if creating the String.prototype.lastIndexOf object fails description: Checking if creating the String.prototype.lastIndexOf object fails
includes:
- $PRINT.js
---*/ ---*/
var __FACTORY = String.prototype.lastIndexOf; var FACTORY = String.prototype.lastIndexOf;
try { assert.throws(TypeError, function() {
var __instance = new __FACTORY; new FACTORY;
$ERROR('#1: __FACTORY = String.prototype.lastIndexOf; __instance = new __FACTORY lead to throwing exception'); });
} catch (e) {
$PRINT(e);
}

View File

@ -5,15 +5,10 @@
info: String.prototype.slice can't be used as constructor info: String.prototype.slice can't be used as constructor
es5id: 15.5.4.13_A7 es5id: 15.5.4.13_A7
description: Checking if creating the String.prototype.slice object fails description: Checking if creating the String.prototype.slice object fails
includes:
- $PRINT.js
---*/ ---*/
var __FACTORY = String.prototype.slice; var FACTORY = String.prototype.slice;
try { assert.throws(TypeError, function() {
var __instance = new __FACTORY; new FACTORY;
$ERROR('#1: __FACTORY = String.prototype.slice; "__instance = new __FACTORY" lead to throwing exception'); });
} catch (e) {
$PRINT(e);
}

View File

@ -13,12 +13,12 @@ includes: [$PRINT.js]
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//CHECK#1 //CHECK#1
try { assert.throws(ReferenceError, function() {
x(); {
$ERROR('#1: "x()" lead to throwing exception'); x();
} catch (e) { }
$PRINT(e.message); });
}
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View File

@ -8,7 +8,6 @@ info: >
VariableStatement is executed, not when the variable is created VariableStatement is executed, not when the variable is created
es5id: 12.2_A1 es5id: 12.2_A1
description: Creating variables after entering the execution scope description: Creating variables after entering the execution scope
includes: [$PRINT.js]
---*/ ---*/
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -25,12 +24,9 @@ try {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//CHECK#2 //CHECK#2
try{ assert.throws(ReferenceError, function() {
__something__undefined = __something__undefined; __something__undefined = __something__undefined;
$ERROR('#2: "__something__undefined = __something__undefined" lead to throwing exception'); });
} catch(e){
$PRINT(e.message);
}
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View File

@ -7,18 +7,14 @@ info: >
reaches the eval statement reaches the eval statement
es5id: 12.2_A5 es5id: 12.2_A5
description: Executing eval("var x") description: Executing eval("var x")
includes: [$PRINT.js]
flags: [noStrict] flags: [noStrict]
---*/ ---*/
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//CHECK#1 //CHECK#1
try{ assert.throws(ReferenceError, function() {
x=x; x=x;
$ERROR('#1: "x=x" lead to throwing exception'); });
}catch(e){
$PRINT(e.message);
};
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////