Skip to content
Snippets Groups Projects
Commit 39b5b727 authored by Brian Terlson's avatar Brian Terlson
Browse files

Merge pull request #392 from anba/remove-runTestCase-throws

Replace runTestCase with assert.throws
parents b155e612 589b638a
No related branches found
No related tags found
No related merge requests found
Showing
with 65 additions and 219 deletions
......@@ -6,14 +6,9 @@ es5id: 15.4.5.1-3.d-1
description: >
Throw RangeError if attempt to set array length property to
4294967296 (2**32)
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(RangeError, function() {
[].length = 4294967296 ;
} catch (e) {
if (e instanceof RangeError) return true;
}
}
runTestCase(testcase);
});
......@@ -6,14 +6,9 @@ es5id: 15.4.5.1-3.d-2
description: >
Throw RangeError if attempt to set array length property to
4294967297 (1+2**32)
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(RangeError, function() {
[].length = 4294967297 ;
} catch (e) {
if (e instanceof RangeError) return true;
}
}
runTestCase(testcase);
});
......@@ -4,15 +4,9 @@
/*---
es5id: 15.4.4.16-1-1
description: Array.prototype.every applied to undefined throws a TypeError
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Array.prototype.every.call(undefined); // TypeError is thrown if value is undefined
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});
......@@ -4,15 +4,9 @@
/*---
es5id: 15.4.4.16-1-2
description: Array.prototype.every applied to null throws a TypeError
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Array.prototype.every.call(null); // TypeError is thrown if value is null
return false;
} catch (e) {
return (e instanceof TypeError);
}
}
runTestCase(testcase);
});
......@@ -7,11 +7,8 @@ description: >
Array.prototype.every throws TypeError exception when 'length' is
an object with toString and valueOf methods that don�t return
primitive values
includes: [runTestCase.js]
---*/
function testcase() {
var callbackfnAccessed = false;
var toStringAccessed = false;
var valueOfAccessed = false;
......@@ -36,12 +33,9 @@ function testcase() {
}
}
};
try {
assert.throws(TypeError, function() {
Array.prototype.every.call(obj, callbackfn);
return false;
} catch (ex) {
return (ex instanceof TypeError) && toStringAccessed && valueOfAccessed && !callbackfnAccessed;
}
}
runTestCase(testcase);
});
assert(toStringAccessed, 'toStringAccessed !== true');
assert(valueOfAccessed, 'valueOfAccessed !== true');
assert.sameValue(callbackfnAccessed, false, 'callbackfnAccessed');
......@@ -4,19 +4,9 @@
/*---
es5id: 15.4.4.16-4-1
description: Array.prototype.every throws TypeError if callbackfn is undefined
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.every();
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.every();
});
......@@ -6,10 +6,8 @@ es5id: 15.4.4.16-4-15
description: >
Array.prototype.every - calling with no callbackfn is the same as
passing undefined for callbackfn
includes: [runTestCase.js]
---*/
function testcase() {
var obj = { 10: 10 };
var lengthAccessed = false;
var loopAccessed = false;
......@@ -29,12 +27,8 @@ function testcase() {
},
configurable: true
});
try {
assert.throws(TypeError, function() {
Array.prototype.every.call(obj);
return false;
} catch (ex) {
return (ex instanceof TypeError) && lengthAccessed && !loopAccessed;
}
}
runTestCase(testcase);
});
assert(lengthAccessed, 'lengthAccessed !== true');
assert.sameValue(loopAccessed, false, 'loopAccessed');
......@@ -4,19 +4,9 @@
/*---
es5id: 15.4.4.16-4-3
description: Array.prototype.every throws TypeError if callbackfn is null
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.every(null);
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.every(null);
});
......@@ -4,19 +4,9 @@
/*---
es5id: 15.4.4.16-4-4
description: Array.prototype.every throws TypeError if callbackfn is boolean
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.every(true);
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.every(true);
});
......@@ -4,19 +4,9 @@
/*---
es5id: 15.4.4.16-4-5
description: Array.prototype.every throws TypeError if callbackfn is number
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.every(5);
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.every(5);
});
......@@ -4,19 +4,9 @@
/*---
es5id: 15.4.4.16-4-6
description: Array.prototype.every throws TypeError if callbackfn is string
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.every("abc");
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.every("abc");
});
......@@ -6,19 +6,9 @@ es5id: 15.4.4.16-4-7
description: >
Array.prototype.every throws TypeError if callbackfn is Object
without a Call internal method
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.every( {} );
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.every( {} );
});
......@@ -6,11 +6,8 @@ es5id: 15.4.4.16-4-8
description: >
Array.prototype.every - side effects produced by step 2 are
visible when an exception occurs
includes: [runTestCase.js]
---*/
function testcase() {
var obj = { 0: 11, 1: 12 };
var accessed = false;
......@@ -22,12 +19,7 @@ function testcase() {
},
configurable: true
});
try {
assert.throws(TypeError, function() {
Array.prototype.every.call(obj, null);
return false;
} catch (ex) {
return ex instanceof TypeError && accessed;
}
}
runTestCase(testcase);
});
assert(accessed, 'accessed !== true');
......@@ -6,11 +6,8 @@ es5id: 15.4.4.16-4-9
description: >
Array.prototype.every - side effects produced by step 3 are
visible when an exception occurs
includes: [runTestCase.js]
---*/
function testcase() {
var obj = { 0: 11, 1: 12 };
var accessed = false;
......@@ -26,12 +23,7 @@ function testcase() {
},
configurable: true
});
try {
assert.throws(TypeError, function() {
Array.prototype.every.call(obj, null);
return false;
} catch (ex) {
return ex instanceof TypeError && accessed;
}
}
runTestCase(testcase);
});
assert(accessed, 'accessed !== true');
......@@ -6,11 +6,8 @@ es5id: 15.4.4.16-7-c-i-30
description: >
Array.prototype.every - unnhandled exceptions happened in getter
terminate iteration on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(val, idx, obj) {
if (idx > 1) {
......@@ -26,12 +23,7 @@ function testcase() {
},
configurable: true
});
try {
assert.throws(RangeError, function() {
Array.prototype.every.call(obj, callbackfn);
return false;
} catch (ex) {
return (ex instanceof RangeError) && !accessed;
}
}
runTestCase(testcase);
});
assert.sameValue(accessed, false, 'accessed');
......@@ -6,11 +6,8 @@ es5id: 15.4.4.16-7-c-i-31
description: >
Array.prototype.every - unhandled exceptions happened in getter
terminate iteration on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(val, idx, obj) {
if (idx > 1) {
......@@ -29,12 +26,7 @@ function testcase() {
},
configurable: true
});
try {
assert.throws(RangeError, function() {
arr.every(callbackfn);
return false;
} catch (ex) {
return (ex instanceof RangeError) && !accessed;
}
}
runTestCase(testcase);
});
assert.sameValue(accessed, false, 'accessed');
......@@ -4,15 +4,9 @@
/*---
es5id: 15.4.4.20-1-1
description: Array.prototype.filter applied to undefined throws a TypeError
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Array.prototype.filter.call(undefined); // TypeError is thrown if value is undefined
return false;
} catch (ex) {
return ex instanceof TypeError;
}
}
runTestCase(testcase);
});
......@@ -4,15 +4,9 @@
/*---
es5id: 15.4.4.20-1-2
description: Array.prototype.filter applied to null throws a TypeError
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(TypeError, function() {
Array.prototype.filter.call(null);
return false;
} catch (ex) {
return ex instanceof TypeError;
}
}
runTestCase(testcase);
});
......@@ -7,11 +7,8 @@ description: >
Array.prototype.filter throws TypeError exception when 'length' is
an object with toString and valueOf methods that don�t return
primitive values
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var firstStepOccured = false;
var secondStepOccured = false;
......@@ -36,12 +33,9 @@ function testcase() {
}
}
};
try {
assert.throws(TypeError, function() {
Array.prototype.filter.call(obj, callbackfn);
return false;
} catch (ex) {
return (ex instanceof TypeError) && !accessed && firstStepOccured && secondStepOccured;
}
}
runTestCase(testcase);
});
assert.sameValue(accessed, false, 'accessed');
assert(firstStepOccured, 'firstStepOccured !== true');
assert(secondStepOccured, 'secondStepOccured !== true');
......@@ -4,19 +4,9 @@
/*---
es5id: 15.4.4.20-4-1
description: Array.prototype.filter throws TypeError if callbackfn is undefined
includes: [runTestCase.js]
---*/
function testcase() {
var arr = new Array(10);
try {
arr.filter();
}
catch(e) {
if(e instanceof TypeError)
return true;
}
}
runTestCase(testcase);
assert.throws(TypeError, function() {
arr.filter();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment