Replace runTestCase with assert.throws [test/built-ins]

This commit is contained in:
André Bargull 2015-08-11 17:44:37 +02:00
parent edc902aff5
commit 589b638ab5
32 changed files with 86 additions and 331 deletions

View File

@ -6,17 +6,9 @@ es5id: 15.9.5.40_1
description: >
Date.prototype.setFullYear - Date.prototype is itself not an
instance of Date
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Date.prototype.setFullYear(2012);
} catch (e) {
if (e instanceof TypeError) {
return true;
}
}
return false;
}
runTestCase(testcase);
});

View File

@ -6,16 +6,9 @@ es5id: 15.9.5.43-0-14
description: >
Date.prototype.toISOString - when value of year is -Infinity
Date.prototype.toISOString throw the RangeError
includes: [runTestCase.js]
---*/
function testcase() {
var date = new Date(-Infinity, 1, 70, 0, 0, 0);
try {
assert.throws(RangeError, function() {
date.toISOString();
} catch (ex) {
return ex instanceof RangeError;
}
}
runTestCase(testcase);
});

View File

@ -6,16 +6,9 @@ es5id: 15.9.5.43-0-15
description: >
Date.prototype.toISOString - value of year is Infinity
Date.prototype.toISOString throw the RangeError
includes: [runTestCase.js]
---*/
function testcase() {
var date = new Date(Infinity, 1, 70, 0, 0, 0);
try {
assert.throws(RangeError, function() {
date.toISOString();
} catch (ex) {
return ex instanceof RangeError;
}
}
runTestCase(testcase);
});

View File

@ -7,17 +7,9 @@ description: >
Date.prototype.toISOString - when this is a String object that
value format is 'YYYY-MM-DDTHH:mm:ss.sssZ'
Date.prototype.toISOString throw the TypeError
includes: [runTestCase.js]
---*/
function testcase() {
var date = new String("1970-01-00000:00:00.000Z");
try {
assert.throws(TypeError, function() {
Date.prototype.toISOString.call(date);
return false;
} catch (ex) {
return ex instanceof TypeError;
}
}
runTestCase(testcase);
});

View File

@ -6,16 +6,9 @@ es5id: 15.9.5.43-0-6
description: >
Date.prototype.toISOString - TypeError is thrown when this is any
other objects instead of Date object
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Date.prototype.toISOString.call([]);
return false;
} catch (ex) {
return ex instanceof TypeError;
}
}
runTestCase(testcase);
});

View File

@ -6,16 +6,9 @@ es5id: 15.9.5.43-0-7
description: >
Date.prototype.toISOString - TypeError is thrown when this is any
primitive values
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Date.prototype.toISOString.call(15);
return false;
} catch (ex) {
return ex instanceof TypeError;
}
}
runTestCase(testcase);
});

View File

@ -7,13 +7,11 @@ description: >
Date.prototype.toISOString - RangeError is thrown when value of
date is Date(1970, 0, -99999999, 0, 0, 0, -1), the time zone is
UTC(0)
includes: [runTestCase.js]
---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr;
try {
assert.throws(RangeError, function() {
if (timeZoneMinutes > 0) {
date = new Date(1970, 0, -99999999, 0, 0, 0, -1);
} else {
@ -21,10 +19,4 @@ function testcase() {
}
dateStr = date.toISOString();
return false;
} catch (e) {
return e instanceof RangeError;
}
}
runTestCase(testcase);
});

View File

@ -7,17 +7,9 @@ description: >
Duplicate seperate parameter name in Function constructor throws
SyntaxError in strict mode
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
Function('a','a','"use strict";');
return false;
}
catch (e) {
return (e instanceof SyntaxError);
}
}
runTestCase(testcase);
});

View File

@ -7,18 +7,9 @@ description: >
Function constructor having a formal parameter named 'eval' throws
SyntaxError if function body is strict mode
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
Function('eval', '"use strict";');
return false;
}
catch (e) {
return (e instanceof SyntaxError);
}
}
runTestCase(testcase);
});

View File

@ -7,18 +7,9 @@ description: >
Duplicate combined parameter name in Function constructor throws
SyntaxError in strict mode
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase()
{
try
{
assert.throws(SyntaxError, function() {
Function('a,a','"use strict";');
return false;
}
catch (e) {
return(e instanceof SyntaxError);
}
}
runTestCase(testcase);
});

View File

@ -9,22 +9,12 @@ es5id: 15.3.4.5-2-1
description: >
Function.prototype.bind throws TypeError if the Target is not
callable (but an instance of Function)
includes: [runTestCase.js]
---*/
function testcase() {
foo.prototype = Function.prototype;
// dummy function
function foo() {}
var f = new foo();
try {
assert.throws(TypeError, function() {
f.bind();
}
catch (e) {
if (e instanceof TypeError) {
return true;
}
}
}
runTestCase(testcase);
});

View File

@ -4,15 +4,9 @@
/*---
es5id: 15.3.4.5-2-10
description: Function.prototype.bind throws TypeError if 'Target' is undefined
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Function.prototype.bind.call(undefined);
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -4,15 +4,9 @@
/*---
es5id: 15.3.4.5-2-11
description: Function.prototype.bind throws TypeError if 'Target' is NULL
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Function.prototype.bind.call(null);
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -4,15 +4,9 @@
/*---
es5id: 15.3.4.5-2-12
description: Function.prototype.bind throws TypeError if 'Target' is a boolean
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Function.prototype.bind.call(true);
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -4,15 +4,9 @@
/*---
es5id: 15.3.4.5-2-13
description: Function.prototype.bind throws TypeError if 'Target' is a number
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Function.prototype.bind.call(5);
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -4,15 +4,9 @@
/*---
es5id: 15.3.4.5-2-14
description: Function.prototype.bind throws TypeError if 'Target' is a string
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Function.prototype.bind.call("abc");
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -6,15 +6,9 @@ es5id: 15.3.4.5-2-15
description: >
Function.prototype.bind throws TypeError if 'Target' is Object
without Call internal method
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Function.prototype.bind.call({});
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -9,22 +9,12 @@ es5id: 15.3.4.5-2-2
description: >
Function.prototype.bind throws TypeError if the Target is not
callable (bind attached to object)
includes: [runTestCase.js]
---*/
function testcase() {
// dummy function
function foo() {}
var f = new foo();
f.bind = Function.prototype.bind;
try {
assert.throws(TypeError, function() {
f.bind();
}
catch (e) {
if (e instanceof TypeError) {
return true;
}
}
}
runTestCase(testcase);
});

View File

@ -9,17 +9,9 @@ es5id: 15.3.4.5-2-7
description: >
Function.prototype.bind throws TypeError if the Target is not
callable (JSON)
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
JSON.bind();
}
catch (e) {
if (e instanceof TypeError) {
return true;
}
}
}
runTestCase(testcase);
});

View File

@ -6,18 +6,10 @@ es5id: 15.3.4.5-20-3
description: >
Function.prototype.bind - [[Set]] attribute of 'caller' property
in 'F' is thrower
includes: [runTestCase.js]
---*/
function testcase() {
function foo() { }
var obj = foo.bind({});
try {
assert.throws(TypeError, function() {
obj.caller = 12;
return false;
} catch (ex) {
return (ex instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -6,18 +6,10 @@ es5id: 15.3.4.5-21-3
description: >
Function.prototype.bind - [[Set]] attribute of 'arguments'
property in 'F' is thrower
includes: [runTestCase.js]
---*/
function testcase() {
function foo() { }
var obj = foo.bind({});
try {
assert.throws(TypeError, function() {
obj.arguments = 12;
return false;
} catch (ex) {
return (ex instanceof TypeError);
}
}
runTestCase(testcase);
});

View File

@ -8,19 +8,9 @@ info: >
step 4 in 11.2.2 should throw a TypeError exception.
es5id: 15.12-0-2
description: JSON must not support the [[Construct]] method
includes: [runTestCase.js]
---*/
function testcase() {
var o = JSON;
try {
assert.throws(TypeError, function() {
var j = new JSON();
}
catch (e) {
if (e instanceof TypeError) {
return true;
}
}
}
runTestCase(testcase);
});

View File

@ -8,19 +8,9 @@ info: >
step 5 in 11.2.3 should throw a TypeError exception.
es5id: 15.12-0-3
description: JSON must not support the [[Call]] method
includes: [runTestCase.js]
---*/
function testcase() {
var o = JSON;
try {
assert.throws(TypeError, function() {
var j = JSON();
}
catch (e) {
if (e instanceof TypeError) {
return true;
}
}
}
runTestCase(testcase);
});

View File

@ -4,17 +4,9 @@
/*---
es5id: 15.10.7.2-1
description: RegExp.prototype.global is a non-generic accessor property
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
RegExp.prototype.global;
} catch (e) {
if (e instanceof TypeError) {
return true;
}
}
return false;
}
runTestCase(testcase);
});

View File

@ -4,17 +4,9 @@
/*---
es5id: 15.10.7.3-1
description: RegExp.prototype.ignoreCase is a non-generic accessor property
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
RegExp.prototype.ignoreCase;
} catch (e) {
if (e instanceof TypeError) {
return true;
}
}
return false;
}
runTestCase(testcase);
});

View File

@ -4,17 +4,9 @@
/*---
es5id: 15.10.7.4-1
description: RegExp.prototype.multiline is a non-generic accessor property
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
RegExp.prototype.multiline;
} catch (e) {
if (e instanceof TypeError) {
return true;
}
}
return false;
}
runTestCase(testcase);
});

View File

@ -4,17 +4,9 @@
/*---
es5id: 15.10.7.1-1
description: RegExp.prototype.source is a non-generic accessor property
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
RegExp.prototype.source;
} catch (e) {
if (e instanceof TypeError) {
return true;
}
}
return false;
}
runTestCase(testcase);
});

View File

@ -4,18 +4,9 @@
/*---
es5id: 15.5.4.20-1-1
description: String.prototype.trim throws TypeError when string is undefined
includes: [runTestCase.js]
---*/
function testcase() {
try
{
String.prototype.trim.call(undefined);
return false;
}
catch(e)
{
return e instanceof TypeError;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
String.prototype.trim.call(undefined);
});

View File

@ -4,18 +4,9 @@
/*---
es5id: 15.5.4.20-1-2
description: String.prototype.trim throws TypeError when string is null
includes: [runTestCase.js]
---*/
function testcase() {
try
{
String.prototype.trim.call(null);
return false;
}
catch(e)
{
return e instanceof TypeError;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
String.prototype.trim.call(null);
});

View File

@ -7,10 +7,8 @@ description: >
String.prototype.trim - TypeError exception was thrown when
'this' is an object that both toString and valueOf wouldn't return
primitive value.
includes: [runTestCase.js]
---*/
function testcase() {
var toStringAccessed = false;
var valueOfAccessed = false;
var obj = {
@ -23,11 +21,8 @@ function testcase() {
return {};
}
};
try {
assert.throws(TypeError, function() {
String.prototype.trim.call(obj);
return false;
} catch (e) {
return valueOfAccessed && toStringAccessed && (e instanceof TypeError);
}
}
runTestCase(testcase);
});
assert(valueOfAccessed, 'valueOfAccessed !== true');
assert(toStringAccessed, 'toStringAccessed !== true');

View File

@ -7,15 +7,9 @@ description: >
Strict Mode - TypeError is thrown when changing the value of a
Value Property of the Global Object under strict mode (NaN)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
NaN = 12;
return false;
} catch (e) {
return e instanceof TypeError;
}
}
runTestCase(testcase);
});

View File

@ -7,15 +7,9 @@ description: >
Strict Mode - TypeError is thrown when changing the value of a
Value Property of the Global Object under strict mode (undefined)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
undefined = 12;
return false;
} catch (e) {
return e instanceof TypeError;
}
}
runTestCase(testcase);
});