mirror of https://github.com/tc39/test262.git
Replace runTestCase with assert helpers [test/built-ins/Array]
This commit is contained in:
parent
174f24b2f3
commit
a3bfd5a61f
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.5-1
|
||||
description: Array instances have [[Class]] set to 'Array'
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [];
|
||||
var s = Object.prototype.toString.call(a);
|
||||
if (s === '[object Array]') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(s, '[object Array]', 's');
|
||||
|
|
|
@ -4,12 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.5.1-3.d-3
|
||||
description: Set array length property to max value 4294967295 (2**32-1,)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a =[];
|
||||
a.length = 4294967295 ;
|
||||
return a.length===4294967295 ;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.length, 4294967295, 'a.length');
|
||||
|
|
|
@ -6,12 +6,9 @@ es5id: 15.4.5.1-5-1
|
|||
description: >
|
||||
Defining a property named 4294967295 (2**32-1)(not an array
|
||||
element)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a =[];
|
||||
a[4294967295] = "not an array element" ;
|
||||
return a[4294967295] === "not an array element";
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a[4294967295], "not an array element", 'a[4294967295]');
|
||||
|
|
|
@ -6,12 +6,9 @@ es5id: 15.4.5.1-5-2
|
|||
description: >
|
||||
Defining a property named 4294967295 (2**32-1) doesn't change
|
||||
length of the array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a =[0,1,2];
|
||||
a[4294967295] = "not an array element" ;
|
||||
return a.length===3;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.length, 3, 'a.length');
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-0-1
|
||||
description: Array.isArray must exist as a function
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var f = Array.isArray;
|
||||
if (typeof(f) === "function") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(typeof(f), "function", 'typeof(f)');
|
||||
|
|
|
@ -4,12 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-0-2
|
||||
description: Array.isArray must exist as a function taking 1 parameter
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
if (Array.isArray.length === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray.length, 1, 'Array.isArray.length');
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-0-3
|
||||
description: Array.isArray return true if its argument is an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [];
|
||||
var b = Array.isArray(a);
|
||||
if (b === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(b, true, 'b');
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-0-4
|
||||
description: Array.isArray return false if its argument is not an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var b_num = Array.isArray(42);
|
||||
var b_undef = Array.isArray(undefined);
|
||||
var b_bool = Array.isArray(true);
|
||||
|
@ -15,13 +13,10 @@ function testcase() {
|
|||
var b_obj = Array.isArray({});
|
||||
var b_null = Array.isArray(null);
|
||||
|
||||
if (b_num === false &&
|
||||
b_undef === false &&
|
||||
b_bool === false &&
|
||||
b_str === false &&
|
||||
b_obj === false &&
|
||||
b_null === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(b_num, false, 'b_num');
|
||||
assert.sameValue(b_undef, false, 'b_undef');
|
||||
assert.sameValue(b_bool, false, 'b_bool');
|
||||
assert.sameValue(b_str, false, 'b_str');
|
||||
assert.sameValue(b_obj, false, 'b_obj');
|
||||
assert.sameValue(b_null, false, 'b_null');
|
||||
|
|
|
@ -6,13 +6,8 @@ es5id: 15.4.3.2-0-5
|
|||
description: >
|
||||
Array.isArray return true if its argument is an Array
|
||||
(Array.prototype)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var b = Array.isArray(Array.prototype);
|
||||
if (b === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(b, true, 'b');
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-0-6
|
||||
description: Array.isArray return true if its argument is an Array (new Array())
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(10);
|
||||
var b = Array.isArray(a);
|
||||
if (b === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(b, true, 'b');
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-0-7
|
||||
description: Array.isArray returns false if its argument is not an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var o = new Object();
|
||||
o[12] = 13;
|
||||
var b = Array.isArray(o);
|
||||
if (b === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(b, false, 'b');
|
||||
|
|
|
@ -4,17 +4,12 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-13
|
||||
description: Array.isArray applied to Arguments object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arg;
|
||||
|
||||
(function fun() {
|
||||
arg = arguments;
|
||||
}(1, 2, 3));
|
||||
|
||||
return !Array.isArray(arg);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(arg), false, 'Array.isArray(arg)');
|
||||
|
|
|
@ -4,16 +4,12 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-2-1
|
||||
description: Array.isArray applied to an object with an array as the prototype
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = [];
|
||||
var Con = function () { };
|
||||
Con.prototype = proto;
|
||||
|
||||
var child = new Con();
|
||||
return !Array.isArray(child);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.isArray(child), false, 'Array.isArray(child)');
|
||||
|
|
|
@ -6,17 +6,12 @@ es5id: 15.4.3.2-2-2
|
|||
description: >
|
||||
Array.isArray applied to an object with Array.prototype as the
|
||||
prototype
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = Array.prototype;
|
||||
var Con = function () { };
|
||||
Con.prototype = proto;
|
||||
|
||||
var child = new Con();
|
||||
|
||||
return !Array.isArray(child);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(child), false, 'Array.isArray(child)');
|
||||
|
|
|
@ -6,12 +6,10 @@ es5id: 15.4.4.12-9-a-1
|
|||
description: >
|
||||
Array.prototype.splice - 'from' is the result of
|
||||
ToString(actualStart+k) in an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var arrObj = [1, 2, 3];
|
||||
var newArrObj = arrObj.splice(-2, 1);
|
||||
return newArrObj.length === 1 && newArrObj[0] === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(newArrObj.length, 1, 'newArrObj.length');
|
||||
assert.sameValue(newArrObj[0], 2, 'newArrObj[0]');
|
||||
|
|
Loading…
Reference in New Issue