Skip to content
Snippets Groups Projects
Commit 7510a91a authored by André Bargull's avatar André Bargull
Browse files

Replace runTestCase with assert helpers [test/built-ins/Array/prototype/indexOf]

parent 659aa4c0
No related branches found
No related tags found
No related merge requests found
Showing
with 27 additions and 124 deletions
...@@ -4,13 +4,8 @@ ...@@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-0-1 es5id: 15.4.4.14-0-1
description: Array.prototype.indexOf must exist as a function description: Array.prototype.indexOf must exist as a function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var f = Array.prototype.indexOf; var f = Array.prototype.indexOf;
if (typeof(f) === "function") {
return true; assert.sameValue(typeof(f), "function", 'typeof(f)');
}
}
runTestCase(testcase);
...@@ -4,12 +4,6 @@ ...@@ -4,12 +4,6 @@
/*--- /*---
es5id: 15.4.4.14-0-2 es5id: 15.4.4.14-0-2
description: Array.prototype.indexOf has a length property whose value is 1. description: Array.prototype.indexOf has a length property whose value is 1.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.sameValue(Array.prototype.indexOf.length, 1, 'Array.prototype.indexOf.length');
if (Array.prototype.indexOf.length === 1) {
return true;
}
}
runTestCase(testcase);
...@@ -4,15 +4,10 @@ ...@@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-11 es5id: 15.4.4.14-1-11
description: Array.prototype.indexOf applied to Date object description: Array.prototype.indexOf applied to Date object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new Date(); var obj = new Date();
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -4,15 +4,10 @@ ...@@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-12 es5id: 15.4.4.14-1-12
description: Array.prototype.indexOf applied to RegExp object description: Array.prototype.indexOf applied to RegExp object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new RegExp(); var obj = new RegExp();
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -4,15 +4,10 @@ ...@@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-14 es5id: 15.4.4.14-1-14
description: Array.prototype.indexOf applied to Error object description: Array.prototype.indexOf applied to Error object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new SyntaxError(); var obj = new SyntaxError();
obj[1] = true; obj[1] = true;
obj.length = 2; obj.length = 2;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -4,16 +4,11 @@ ...@@ -4,16 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-1-15 es5id: 15.4.4.14-1-15
description: Array.prototype.indexOf applied to Arguments object description: Array.prototype.indexOf applied to Arguments object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function fun() { function fun() {
return arguments; return arguments;
} }
var obj = fun(1, true, 3); var obj = fun(1, true, 3);
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -4,15 +4,10 @@ ...@@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-4 es5id: 15.4.4.14-1-4
description: Array.prototype.indexOf applied to Boolean Object description: Array.prototype.indexOf applied to Boolean Object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new Boolean(false); var obj = new Boolean(false);
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -4,15 +4,10 @@ ...@@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-6 es5id: 15.4.4.14-1-6
description: Array.prototype.indexOf applied to Number object description: Array.prototype.indexOf applied to Number object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new Number(-3); var obj = new Number(-3);
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -4,13 +4,8 @@ ...@@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-1-8 es5id: 15.4.4.14-1-8
description: Array.prototype.indexOf applied to String object description: Array.prototype.indexOf applied to String object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new String("null"); var obj = new String("null");
return Array.prototype.indexOf.call(obj, 'l') === 2; assert.sameValue(Array.prototype.indexOf.call(obj, 'l'), 2, 'Array.prototype.indexOf.call(obj, "l")');
}
runTestCase(testcase);
...@@ -4,16 +4,11 @@ ...@@ -4,16 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-1-9 es5id: 15.4.4.14-1-9
description: Array.prototype.indexOf applied to Function object description: Array.prototype.indexOf applied to Function object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = function (a, b) { var obj = function (a, b) {
return a + b; return a + b;
}; };
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -6,10 +6,8 @@ es5id: 15.4.4.14-10-2 ...@@ -6,10 +6,8 @@ es5id: 15.4.4.14-10-2
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 and does not Array.prototype.indexOf returns -1 if 'length' is 0 and does not
access any other properties access any other properties
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var accessed = false; var accessed = false;
var f = {length: 0}; var f = {length: 0};
Object.defineProperty(f,"0",{get: function () {accessed = true; return 1;}}); Object.defineProperty(f,"0",{get: function () {accessed = true; return 1;}});
...@@ -17,8 +15,6 @@ function testcase() { ...@@ -17,8 +15,6 @@ function testcase() {
var i = Array.prototype.indexOf.call(f,1); var i = Array.prototype.indexOf.call(f,1);
if (i === -1 && accessed==false) {
return true; assert.sameValue(i, -1, 'i');
} assert.sameValue(accessed, false, 'accessed');
}
runTestCase(testcase);
...@@ -6,13 +6,10 @@ es5id: 15.4.4.14-2-1 ...@@ -6,13 +6,10 @@ es5id: 15.4.4.14-2-1
description: > description: >
Array.prototype.indexOf - 'length' is own data property on an Array.prototype.indexOf - 'length' is own data property on an
Array-like object Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var objOne = { 1: true, length: 2 }; var objOne = { 1: true, length: 2 };
var objTwo = { 2: true, length: 2 }; var objTwo = { 2: true, length: 2 };
return Array.prototype.indexOf.call(objOne, true) === 1 &&
Array.prototype.indexOf.call(objTwo, true) === -1; assert.sameValue(Array.prototype.indexOf.call(objOne, true), 1, 'Array.prototype.indexOf.call(objOne, true)');
} assert.sameValue(Array.prototype.indexOf.call(objTwo, true), -1, 'Array.prototype.indexOf.call(objTwo, true)');
runTestCase(testcase);
...@@ -4,11 +4,8 @@ ...@@ -4,11 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-2-10 es5id: 15.4.4.14-2-10
description: Array.prototype.indexOf - 'length' is inherited accessor property description: Array.prototype.indexOf - 'length' is inherited accessor property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
get: function () { get: function () {
...@@ -25,7 +22,5 @@ function testcase() { ...@@ -25,7 +22,5 @@ function testcase() {
var childTwo = new Con(); var childTwo = new Con();
childTwo[2] = true; childTwo[2] = true;
return Array.prototype.indexOf.call(childOne, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)');
Array.prototype.indexOf.call(childTwo, true) === -1; assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)');
}
runTestCase(testcase);
...@@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-11 ...@@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-11
description: > description: >
Array.prototype.indexOf - 'length' is own accessor property Array.prototype.indexOf - 'length' is own accessor property
without a get function without a get function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: true }; var obj = { 1: true };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
set: function () { }, set: function () { },
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-13 ...@@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-13
description: > description: >
Array.prototype.indexOf - 'length' is inherited accessor property Array.prototype.indexOf - 'length' is inherited accessor property
without a get function without a get function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
set: function () { }, set: function () { },
...@@ -23,6 +20,4 @@ function testcase() { ...@@ -23,6 +20,4 @@ function testcase() {
var child = new Con(); var child = new Con();
child[1] = true; child[1] = true;
return Array.prototype.indexOf.call(child, true) === -1; assert.sameValue(Array.prototype.indexOf.call(child, true), -1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);
...@@ -4,13 +4,8 @@ ...@@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-2-14 es5id: 15.4.4.14-2-14
description: Array.prototype.indexOf - 'length' is undefined property description: Array.prototype.indexOf - 'length' is undefined property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: true, 1: true }; var obj = { 0: true, 1: true };
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);
...@@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-17 ...@@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-17
description: > description: >
Array.prototype.indexOf applied to Arguments object which Array.prototype.indexOf applied to Arguments object which
implements its own property get method implements its own property get method
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var func = function (a, b) { var func = function (a, b) {
arguments[2] = false; arguments[2] = false;
return Array.prototype.indexOf.call(arguments, true) === 1 && return Array.prototype.indexOf.call(arguments, true) === 1 &&
Array.prototype.indexOf.call(arguments, false) === -1; Array.prototype.indexOf.call(arguments, false) === -1;
}; };
return func(0, true); assert(func(0, true), 'func(0, true) !== true');
}
runTestCase(testcase);
...@@ -6,18 +6,13 @@ es5id: 15.4.4.14-2-19 ...@@ -6,18 +6,13 @@ es5id: 15.4.4.14-2-19
description: > description: >
Array.prototype.indexOf applied to Function object which Array.prototype.indexOf applied to Function object which
implements its own property get method implements its own property get method
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = function (a, b) { var obj = function (a, b) {
return a + b; return a + b;
}; };
obj[1] = "b"; obj[1] = "b";
obj[2] = "c"; obj[2] = "c";
return Array.prototype.indexOf.call(obj, obj[1]) === 1 && assert.sameValue(Array.prototype.indexOf.call(obj, obj[1]), 1, 'Array.prototype.indexOf.call(obj, obj[1])');
Array.prototype.indexOf.call(obj, obj[2]) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, obj[2]), -1, 'Array.prototype.indexOf.call(obj, obj[2])');
}
runTestCase(testcase);
...@@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-3 ...@@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-3
description: > description: >
Array.prototype.indexOf - 'length' is own data property that Array.prototype.indexOf - 'length' is own data property that
overrides an inherited data property on an Array-like object overrides an inherited data property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = { length: 0 }; var proto = { length: 0 };
var Con = function () {}; var Con = function () {};
...@@ -20,6 +17,4 @@ function testcase() { ...@@ -20,6 +17,4 @@ function testcase() {
child.length = 2; child.length = 2;
child[1] = true; child[1] = true;
return Array.prototype.indexOf.call(child, true) === 1; assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);
...@@ -6,10 +6,8 @@ es5id: 15.4.4.14-2-5 ...@@ -6,10 +6,8 @@ es5id: 15.4.4.14-2-5
description: > description: >
Array.prototype.indexOf - 'length' is own data property that Array.prototype.indexOf - 'length' is own data property that
overrides an inherited accessor property on an Array-like object overrides an inherited accessor property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
get: function () { get: function () {
...@@ -29,6 +27,4 @@ function testcase() { ...@@ -29,6 +27,4 @@ function testcase() {
}); });
child[1] = true; child[1] = true;
return Array.prototype.indexOf.call(child, true) === 1; assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment