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