diff options
Diffstat (limited to 'test/built-ins/Array/prototype/reduce')
9 files changed, 27 insertions, 93 deletions
diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js index 20e18205e..5b665af15 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js @@ -6,25 +6,17 @@ es5id: 15.4.4.21-4-10 description: > Array.prototype.reduce - the exception is not thrown if exception was thrown by step 2 -includes: [runTestCase.js] ---*/ -function testcase() { - var obj = { 0: 11, 1: 12 }; Object.defineProperty(obj, "length", { get: function () { - throw new SyntaxError(); + throw new Test262Error(); }, configurable: true }); - try { +assert.throws(Test262Error, function() { Array.prototype.reduce.call(obj, undefined); - return false; - } catch (ex) { - return !(ex instanceof TypeError); - } - } -runTestCase(testcase); +}); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js index 2b77f84c0..3c6dce4a6 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js @@ -6,29 +6,21 @@ es5id: 15.4.4.21-4-11 description: > Array.prototype.reduce - the exception is not thrown if exception was thrown by step 3 -includes: [runTestCase.js] ---*/ -function testcase() { - var obj = { 0: 11, 1: 12 }; Object.defineProperty(obj, "length", { get: function () { return { toString: function () { - throw new SyntaxError(); + throw new Test262Error(); } }; }, configurable: true }); - try { +assert.throws(Test262Error, function() { Array.prototype.reduce.call(obj, undefined); - return false; - } catch (ex) { - return !(ex instanceof TypeError); - } - } -runTestCase(testcase); +}); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js index 8b1dbfc22..8228c57d2 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js @@ -6,11 +6,8 @@ es5id: 15.4.4.21-5-12 description: > Array.prototype.reduce - the exception is not thrown if exception was thrown by step 2 -includes: [runTestCase.js] ---*/ -function testcase() { - function callbackfn(prevVal, curVal, idx, obj) { return (curVal > 10); } @@ -19,16 +16,11 @@ function testcase() { Object.defineProperty(obj, "length", { get: function () { - throw new SyntaxError(); + throw new Test262Error(); }, configurable: true }); - try { +assert.throws(Test262Error, function() { Array.prototype.reduce.call(obj, callbackfn); - return false; - } catch (ex) { - return !(ex instanceof TypeError); - } - } -runTestCase(testcase); +}); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js index 09e577207..f2b22add7 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js @@ -6,11 +6,8 @@ es5id: 15.4.4.21-5-13 description: > Array.prototype.reduce - the exception is not thrown if exception was thrown by step 3 -includes: [runTestCase.js] ---*/ -function testcase() { - function callbackfn(prevVal, curVal, idx, obj) { return (curVal > 10); } @@ -21,19 +18,13 @@ function testcase() { get: function () { return { toString: function () { - throw new SyntaxError(); + throw new Test262Error(); } }; }, configurable: true }); - - try { +assert.throws(Test262Error, function() { Array.prototype.reduce.call(obj, callbackfn); - return false; - } catch (ex) { - return !(ex instanceof TypeError); - } - } -runTestCase(testcase); +}); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js index 911f588e6..453ce6bf4 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js @@ -4,11 +4,8 @@ /*--- es5id: 15.4.4.21-8-b-1 description: Array.prototype.reduce - no observable effects occur if 'len' is 0 -includes: [runTestCase.js] ---*/ -function testcase() { - var accessed = false; var obj = { length: 0 }; @@ -21,11 +18,8 @@ function testcase() { configurable: true }); - try { +assert.throws(TypeError, function() { Array.prototype.reduce.call(obj, function () { }); - return false; - } catch (ex) { - return !accessed; - } - } -runTestCase(testcase); +}); + +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js index 084a2c049..a74acf7bd 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js @@ -6,25 +6,17 @@ es5id: 15.4.4.21-8-c-7 description: > Array.prototype.reduce - the exception is not thrown if exception was thrown by step 2 -includes: [runTestCase.js] ---*/ -function testcase() { - var obj = {}; Object.defineProperty(obj, "length", { get: function () { - throw new SyntaxError(); + throw new Test262Error(); }, configurable: true }); - try { +assert.throws(Test262Error, function() { Array.prototype.reduce.call(obj, function () { }); - return false; - } catch (ex) { - return !(ex instanceof TypeError); - } - } -runTestCase(testcase); +}); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js index 019b6eddf..689579062 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js @@ -6,29 +6,21 @@ es5id: 15.4.4.21-8-c-8 description: > Array.prototype.reduce - the exception is not thrown if exception was thrown by step 3 -includes: [runTestCase.js] ---*/ -function testcase() { - var obj = {}; Object.defineProperty(obj, "length", { get: function () { return { toString: function () { - throw new SyntaxError(); + throw new Test262Error(); } }; }, configurable: true }); - try { +assert.throws(Test262Error, function() { Array.prototype.reduce.call(obj, function () { }); - return false; - } catch (ex) { - return !(ex instanceof TypeError); - } - } -runTestCase(testcase); +}); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js index 027029012..b92e59ff2 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js @@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-3 description: > Array.prototype.reduce doesn't visit deleted elements in array after the call -includes: [runTestCase.js] ---*/ -function testcase() { - function callbackfn(prevVal, curVal, idx, obj) { delete arr[3]; @@ -19,8 +16,6 @@ function testcase() { } var arr = ['1',2,3,4,5]; - if(arr.reduce(callbackfn) === "123" ) // two elements deleted - return true; - - } -runTestCase(testcase); + +// two elements deleted +assert.sameValue(arr.reduce(callbackfn), "123", 'arr.reduce(callbackfn)'); diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js index aa3c35f04..709c1db2f 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js @@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-6 description: > Array.prototype.reduce visits deleted element in array after the call when same index is also present in prototype -includes: [runTestCase.js] ---*/ -function testcase() { - function callbackfn(prevVal, curVal, idx, obj) { delete arr[3]; @@ -23,8 +20,5 @@ function testcase() { var res = arr.reduce(callbackfn); delete Array.prototype[4]; - if(res === "1235" ) //one element acually deleted - return true; - - } -runTestCase(testcase); +//one element acually deleted +assert.sameValue(res, "1235", 'res'); |