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

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

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