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/Object/{getOwnPropertyNames, keys}]
This commit is contained in:
parent
ed0a2bad55
commit
c2a61d1735
@ -4,12 +4,6 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.4-0-1
|
es5id: 15.2.3.4-0-1
|
||||||
description: Object.getOwnPropertyNames must exist as a function
|
description: Object.getOwnPropertyNames must exist as a function
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
assert.sameValue(typeof(Object.getOwnPropertyNames), "function", 'typeof(Object.getOwnPropertyNames)');
|
||||||
if (typeof(Object.getOwnPropertyNames) === "function") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,12 +6,6 @@ es5id: 15.2.3.4-0-2
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames must exist as a function taking 1
|
Object.getOwnPropertyNames must exist as a function taking 1
|
||||||
parameter
|
parameter
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
assert.sameValue(Object.getOwnPropertyNames.length, 1, 'Object.getOwnPropertyNames.length');
|
||||||
if (Object.getOwnPropertyNames.length === 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,6 @@ es5id: 15.2.3.4-1-4
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames does not throw TypeError if 'O' is a
|
Object.getOwnPropertyNames does not throw TypeError if 'O' is a
|
||||||
boolean
|
boolean
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Object.getOwnPropertyNames(true);
|
Object.getOwnPropertyNames(true);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,6 @@ es5id: 15.2.3.4-1-5
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames does not throw TypeError if 'O' is a
|
Object.getOwnPropertyNames does not throw TypeError if 'O' is a
|
||||||
string
|
string
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Object.getOwnPropertyNames("abc");
|
Object.getOwnPropertyNames("abc");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,6 @@ es5id: 15.2.3.4-1
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames does not throw TypeError if type of
|
Object.getOwnPropertyNames does not throw TypeError if type of
|
||||||
first param is not Object
|
first param is not Object
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Object.getOwnPropertyNames(0);
|
Object.getOwnPropertyNames(0);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,14 +6,9 @@ es5id: 15.2.3.4-2-1
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - returned array is an array according
|
Object.getOwnPropertyNames - returned array is an array according
|
||||||
to Array.isArray
|
to Array.isArray
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return Array.isArray(result);
|
assert(Array.isArray(result), 'Array.isArray(result) !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,13 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.4-2-2
|
es5id: 15.2.3.4-2-2
|
||||||
description: Object.getOwnPropertyNames - returned array is an instance of Array
|
description: Object.getOwnPropertyNames - returned array is an instance of Array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return result instanceof Array;
|
assert(result instanceof Array, 'result instanceof Array !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,14 +6,9 @@ es5id: 15.2.3.4-2-3
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - length of returned array is
|
Object.getOwnPropertyNames - length of returned array is
|
||||||
initialized to 0
|
initialized to 0
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return result.length === 0;
|
assert.sameValue(result.length, 0, 'result.length');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,14 +6,11 @@ es5id: 15.2.3.4-3-1
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - elements of the returned array start
|
Object.getOwnPropertyNames - elements of the returned array start
|
||||||
from index 0
|
from index 0
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: 1001 };
|
var obj = { prop1: 1001 };
|
||||||
|
|
||||||
var arr = Object.getOwnPropertyNames(obj);
|
var arr = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return arr.hasOwnProperty(0) && arr[0] === "prop1";
|
assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true');
|
||||||
}
|
assert.sameValue(arr[0], "prop1", 'arr[0]');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,15 +4,10 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.4-4-2
|
es5id: 15.2.3.4-4-2
|
||||||
description: Object.getOwnPropertyNames returns array of property names (Object)
|
description: Object.getOwnPropertyNames returns array of property names (Object)
|
||||||
includes:
|
includes: [arrayContains.js]
|
||||||
- runTestCase.js
|
|
||||||
- arrayContains.js
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var result = Object.getOwnPropertyNames(Object);
|
var result = Object.getOwnPropertyNames(Object);
|
||||||
var expResult = ["getPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyNames", "create", "defineProperty", "defineProperties", "seal", "freeze", "preventExtensions", "isSealed", "isFrozen", "isExtensible", "keys", "prototype", "length"];
|
var expResult = ["getPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyNames", "create", "defineProperty", "defineProperties", "seal", "freeze", "preventExtensions", "isSealed", "isFrozen", "isExtensible", "keys", "prototype", "length"];
|
||||||
|
|
||||||
return arrayContains(result, expResult);
|
assert(arrayContains(result, expResult), 'arrayContains(result, expResult) !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,15 +6,10 @@ es5id: 15.2.3.4-4-38
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - own data properties are pushed into
|
Object.getOwnPropertyNames - own data properties are pushed into
|
||||||
the returned array
|
the returned array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
|
|
||||||
var obj = { "a": "a" };
|
var obj = { "a": "a" };
|
||||||
|
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return result[0] === "a";
|
assert.sameValue(result[0], "a", 'result[0]');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.4-4-39
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - own accessor properties are pushed
|
Object.getOwnPropertyNames - own accessor properties are pushed
|
||||||
into the returned array
|
into the returned array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
Object.defineProperty(obj, "a", {
|
Object.defineProperty(obj, "a", {
|
||||||
get: function () {
|
get: function () {
|
||||||
@ -20,6 +18,4 @@ function testcase() {
|
|||||||
|
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return result[0] === "a";
|
assert.sameValue(result[0], "a", 'result[0]');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,19 +6,13 @@ es5id: 15.2.3.4-4-44
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - own index properties of String object
|
Object.getOwnPropertyNames - own index properties of String object
|
||||||
are pushed into the returned Array
|
are pushed into the returned Array
|
||||||
includes:
|
includes: [compareArray.js]
|
||||||
- runTestCase.js
|
|
||||||
- compareArray.js
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
|
|
||||||
var str = new String("abc");
|
var str = new String("abc");
|
||||||
str[5] = "de";
|
str[5] = "de";
|
||||||
|
|
||||||
var expected = ["0", "1", "2", "5", "length"];
|
var expected = ["0", "1", "2", "5", "length"];
|
||||||
var actual = Object.getOwnPropertyNames(str);
|
var actual = Object.getOwnPropertyNames(str);
|
||||||
|
|
||||||
return compareArray(actual, expected);
|
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,16 +6,11 @@ es5id: 15.2.3.4-4-49
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - own index properties of Array objcect
|
Object.getOwnPropertyNames - own index properties of Array objcect
|
||||||
are pushed into the returned Array
|
are pushed into the returned Array
|
||||||
includes:
|
includes: [compareArray.js]
|
||||||
- runTestCase.js
|
|
||||||
- compareArray.js
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var arr = [0, 1, 2];
|
var arr = [0, 1, 2];
|
||||||
var expected = ["0", "1", "2", "length"];
|
var expected = ["0", "1", "2", "length"];
|
||||||
var actual = Object.getOwnPropertyNames(arr);
|
var actual = Object.getOwnPropertyNames(arr);
|
||||||
|
|
||||||
return compareArray(actual, expected);
|
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.4-4-50
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - non-enumerable own property of 'O' is
|
Object.getOwnPropertyNames - non-enumerable own property of 'O' is
|
||||||
pushed into the returned Array
|
pushed into the returned Array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
Object.defineProperty(obj, "nonEnumerableProp", {
|
Object.defineProperty(obj, "nonEnumerableProp", {
|
||||||
@ -20,6 +18,4 @@ function testcase() {
|
|||||||
|
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
return result[0] === "nonEnumerableProp";
|
assert.sameValue(result[0], "nonEnumerableProp", 'result[0]');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,19 +6,14 @@ es5id: 15.2.3.4-4-b-1
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - descriptor of resultant array is all
|
Object.getOwnPropertyNames - descriptor of resultant array is all
|
||||||
true
|
true
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = new Object();
|
var obj = new Object();
|
||||||
obj.x = 1;
|
obj.x = 1;
|
||||||
obj.y = 2;
|
obj.y = 2;
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
var desc = Object.getOwnPropertyDescriptor(result,"0");
|
var desc = Object.getOwnPropertyDescriptor(result,"0");
|
||||||
if (desc.enumerable === true &&
|
|
||||||
desc.configurable === true &&
|
assert.sameValue(desc.enumerable, true, 'desc.enumerable');
|
||||||
desc.writable === true) {
|
assert.sameValue(desc.configurable, true, 'desc.configurable');
|
||||||
return true;
|
assert.sameValue(desc.writable, true, 'desc.writable');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,12 +6,9 @@ es5id: 15.2.3.4-4-b-2
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - all own properties are pushed into
|
Object.getOwnPropertyNames - all own properties are pushed into
|
||||||
the returned array
|
the returned array
|
||||||
includes:
|
includes: [compareArray.js]
|
||||||
- runTestCase.js
|
|
||||||
- compareArray.js
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { "a": "a" };
|
var obj = { "a": "a" };
|
||||||
|
|
||||||
Object.defineProperty(obj, "b", {
|
Object.defineProperty(obj, "b", {
|
||||||
@ -39,6 +36,4 @@ function testcase() {
|
|||||||
var actual = Object.getOwnPropertyNames(obj);
|
var actual = Object.getOwnPropertyNames(obj);
|
||||||
var expected = ["a", "b", "c", "d"];
|
var expected = ["a", "b", "c", "d"];
|
||||||
|
|
||||||
return compareArray(actual, expected);
|
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.4-4-b-6
|
|||||||
description: >
|
description: >
|
||||||
Object.getOwnPropertyNames - elements of the returned array are
|
Object.getOwnPropertyNames - elements of the returned array are
|
||||||
configurable
|
configurable
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { "a": "a" };
|
var obj = { "a": "a" };
|
||||||
|
|
||||||
var result = Object.getOwnPropertyNames(obj);
|
var result = Object.getOwnPropertyNames(obj);
|
||||||
@ -18,6 +16,5 @@ function testcase() {
|
|||||||
delete result[0];
|
delete result[0];
|
||||||
var afterDeleted = (result.hasOwnProperty("0"));
|
var afterDeleted = (result.hasOwnProperty("0"));
|
||||||
|
|
||||||
return beforeDeleted && !afterDeleted;
|
assert(beforeDeleted, 'beforeDeleted !== true');
|
||||||
}
|
assert.sameValue(afterDeleted, false, 'afterDeleted');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,13 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-0-1
|
es5id: 15.2.3.14-0-1
|
||||||
description: Object.keys must exist as a function
|
description: Object.keys must exist as a function
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var f = Object.keys;
|
var f = Object.keys;
|
||||||
if (typeof(f) === "function") {
|
|
||||||
return true;
|
assert.sameValue(typeof(f), "function", 'typeof(f)');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,12 +4,6 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-0-2
|
es5id: 15.2.3.14-0-2
|
||||||
description: Object.keys must exist as a function taking 1 parameter
|
description: Object.keys must exist as a function taking 1 parameter
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
assert.sameValue(Object.keys.length, 1, 'Object.keys.length');
|
||||||
if (Object.keys.length === 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,6 @@ es5id: 15.2.3.14-1-1
|
|||||||
description: >
|
description: >
|
||||||
Object.keys does not throw TypeError if type of first param is not
|
Object.keys does not throw TypeError if type of first param is not
|
||||||
Object
|
Object
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Object.keys(0);
|
Object.keys(0);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,6 @@ es5id: 15.2.3.14-1-2
|
|||||||
description: >
|
description: >
|
||||||
Object.keys does not throw TypeError if type of first param is not
|
Object.keys does not throw TypeError if type of first param is not
|
||||||
Object (boolean)
|
Object (boolean)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Object.keys(true);
|
Object.keys(true);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,6 @@ es5id: 15.2.3.14-1-3
|
|||||||
description: >
|
description: >
|
||||||
Object.keys does not throw TypeError if type of first param is not
|
Object.keys does not throw TypeError if type of first param is not
|
||||||
Object (string)
|
Object (string)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Object.keys('abc');
|
Object.keys('abc');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,15 +4,10 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-2-1
|
es5id: 15.2.3.14-2-1
|
||||||
description: Object.keys returns the standard built-in Array
|
description: Object.keys returns the standard built-in Array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
|
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
if (Array.isArray(a) === true) {
|
|
||||||
return true;
|
assert.sameValue(Array.isArray(a), true, 'Array.isArray(a)');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,16 +4,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-2-2
|
es5id: 15.2.3.14-2-2
|
||||||
description: Object.keys returns the standard built-in Array (check [[Class]]
|
description: Object.keys returns the standard built-in Array (check [[Class]]
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
|
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
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,10 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-2-3
|
es5id: 15.2.3.14-2-3
|
||||||
description: Object.keys returns the standard built-in Array (Array overridden)
|
description: Object.keys returns the standard built-in Array (Array overridden)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
function Array() { }
|
function Array() { }
|
||||||
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
@ -15,8 +13,5 @@ function testcase() {
|
|||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
|
|
||||||
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,15 +4,10 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-2-4
|
es5id: 15.2.3.14-2-4
|
||||||
description: Object.keys returns the standard built-in Array that is extensible
|
description: Object.keys returns the standard built-in Array that is extensible
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
|
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
if (Object.isExtensible(a) === true) {
|
|
||||||
return true;
|
assert.sameValue(Object.isExtensible(a), true, 'Object.isExtensible(a)');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,15 +4,10 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-2-5
|
es5id: 15.2.3.14-2-5
|
||||||
description: Object.keys returns the standard built-in Array that is not sealed
|
description: Object.keys returns the standard built-in Array that is not sealed
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
|
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
if (Object.isSealed(a) === false) {
|
|
||||||
return true;
|
assert.sameValue(Object.isSealed(a), false, 'Object.isSealed(a)');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,15 +4,10 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-2-6
|
es5id: 15.2.3.14-2-6
|
||||||
description: Object.keys returns the standard built-in Array that is not frozen
|
description: Object.keys returns the standard built-in Array that is not frozen
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
|
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
if (Object.isFrozen(a) === false) {
|
|
||||||
return true;
|
assert.sameValue(Object.isFrozen(a), false, 'Object.isFrozen(a)');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-2-7
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - 'n' is 0 when 'O' doesn't contain own enumerable
|
Object.keys - 'n' is 0 when 'O' doesn't contain own enumerable
|
||||||
data or accessor properties
|
data or accessor properties
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop1", {
|
Object.defineProperty(obj, "prop1", {
|
||||||
@ -28,6 +26,4 @@ function testcase() {
|
|||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return arr.length === 0;
|
assert.sameValue(arr.length, 0, 'arr.length');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-2-8
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - 'n' is the correct value when enumerable properties
|
Object.keys - 'n' is the correct value when enumerable properties
|
||||||
exist in 'O'
|
exist in 'O'
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = {
|
var obj = {
|
||||||
prop1: 1001,
|
prop1: 1001,
|
||||||
prop2: function () {
|
prop2: function () {
|
||||||
@ -33,6 +31,6 @@ function testcase() {
|
|||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return (arr.length === 2) && (arr[0] === "prop1") && (arr[1] === "prop2");
|
assert.sameValue(arr.length, 2, 'arr.length');
|
||||||
}
|
assert.sameValue(arr[0], "prop1", 'arr[0]');
|
||||||
runTestCase(testcase);
|
assert.sameValue(arr[1], "prop2", 'arr[1]');
|
||||||
|
@ -6,17 +6,12 @@ es5id: 15.2.3.14-3-1
|
|||||||
description: >
|
description: >
|
||||||
Object.keys returns the standard built-in Array containing own
|
Object.keys returns the standard built-in Array containing own
|
||||||
enumerable properties
|
enumerable properties
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = { x: 1, y: 2};
|
var o = { x: 1, y: 2};
|
||||||
|
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
if (a.length === 2 &&
|
|
||||||
a[0] === 'x' &&
|
assert.sameValue(a.length, 2, 'a.length');
|
||||||
a[1] === 'y') {
|
assert.sameValue(a[0], 'x', 'a[0]');
|
||||||
return true;
|
assert.sameValue(a[1], 'y', 'a[1]');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,17 +6,12 @@ es5id: 15.2.3.14-3-2
|
|||||||
description: >
|
description: >
|
||||||
Object.keys returns the standard built-in Array containing own
|
Object.keys returns the standard built-in Array containing own
|
||||||
enumerable properties (function)
|
enumerable properties (function)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
function foo() {}
|
function foo() {}
|
||||||
foo.x = 1;
|
foo.x = 1;
|
||||||
|
|
||||||
var a = Object.keys(foo);
|
var a = Object.keys(foo);
|
||||||
if (a.length === 1 &&
|
|
||||||
a[0] === 'x') {
|
assert.sameValue(a.length, 1, 'a.length');
|
||||||
return true;
|
assert.sameValue(a[0], 'x', 'a[0]');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,16 +6,11 @@ es5id: 15.2.3.14-3-3
|
|||||||
description: >
|
description: >
|
||||||
Object.keys returns the standard built-in Array containing own
|
Object.keys returns the standard built-in Array containing own
|
||||||
enumerable properties (array)
|
enumerable properties (array)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = [1, 2];
|
var o = [1, 2];
|
||||||
var a = Object.keys(o);
|
var a = Object.keys(o);
|
||||||
if (a.length === 2 &&
|
|
||||||
a[0] === '0' &&
|
assert.sameValue(a.length, 2, 'a.length');
|
||||||
a[1] === '1') {
|
assert.sameValue(a[0], '0', 'a[0]');
|
||||||
return true;
|
assert.sameValue(a[1], '1', 'a[1]');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-3-4
|
|||||||
description: >
|
description: >
|
||||||
Object.keys of an arguments object returns the indices of the
|
Object.keys of an arguments object returns the indices of the
|
||||||
given arguments
|
given arguments
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
function testArgs2(x, y, z) {
|
function testArgs2(x, y, z) {
|
||||||
// Properties of the arguments object are enumerable.
|
// Properties of the arguments object are enumerable.
|
||||||
var a = Object.keys(arguments);
|
var a = Object.keys(arguments);
|
||||||
@ -28,6 +26,7 @@ function testcase() {
|
|||||||
if (a.length === 4 && a[0] in arguments && a[1] in arguments && a[2] in arguments && a[3] in arguments)
|
if (a.length === 4 && a[0] in arguments && a[1] in arguments && a[2] in arguments && a[3] in arguments)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return testArgs2(1, 2) && testArgs3(1, 2, 3) && testArgs4(1, 2, 3, 4);
|
|
||||||
}
|
assert(testArgs2(1, 2), 'testArgs2(1, 2) !== true');
|
||||||
runTestCase(testcase);
|
assert(testArgs3(1, 2, 3), 'testArgs3(1, 2, 3) !== true');
|
||||||
|
assert(testArgs4(1, 2, 3, 4), 'testArgs4(1, 2, 3, 4) !== true');
|
||||||
|
@ -6,14 +6,10 @@ es5id: 15.2.3.14-3-6
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - returns the standard built-in Array (instanceof
|
Object.keys - returns the standard built-in Array (instanceof
|
||||||
Array)
|
Array)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return arr instanceof Array;
|
assert(arr instanceof Array, 'arr instanceof Array !== true');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-3-7
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - length of the returned array equals the number of
|
Object.keys - length of the returned array equals the number of
|
||||||
own enumerable properties of 'O'
|
own enumerable properties of 'O'
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: 1001, prop2: 1002 };
|
var obj = { prop1: 1001, prop2: 1002 };
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop3", {
|
Object.defineProperty(obj, "prop3", {
|
||||||
@ -28,6 +26,4 @@ function testcase() {
|
|||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return arr.length === 3;
|
assert.sameValue(arr.length, 3, 'arr.length');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 15.2.3.14-4-1
|
es5id: 15.2.3.14-4-1
|
||||||
description: Object.keys - elements of the returned array start from index 0
|
description: Object.keys - elements of the returned array start from index 0
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: 1001, prop2: 1002 };
|
var obj = { prop1: 1001, prop2: 1002 };
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop3", {
|
Object.defineProperty(obj, "prop3", {
|
||||||
@ -26,6 +24,5 @@ function testcase() {
|
|||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return arr.hasOwnProperty(0) && arr[0] === "prop1";
|
assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true');
|
||||||
}
|
assert.sameValue(arr[0], "prop1", 'arr[0]');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-5-1
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - own enumerable data property of 'O' is defined in
|
Object.keys - own enumerable data property of 'O' is defined in
|
||||||
returned array
|
returned array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { };
|
var obj = { };
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
@ -20,6 +18,5 @@ function testcase() {
|
|||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return arr.hasOwnProperty(0) && arr[0] === "prop";
|
assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true');
|
||||||
}
|
assert.sameValue(arr[0], "prop", 'arr[0]');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-5-2
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - own enumerable accessor property of 'O' is defined
|
Object.keys - own enumerable accessor property of 'O' is defined
|
||||||
in returned array
|
in returned array
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { };
|
var obj = { };
|
||||||
|
|
||||||
Object.defineProperty(obj, "prop", {
|
Object.defineProperty(obj, "prop", {
|
||||||
@ -22,6 +20,5 @@ function testcase() {
|
|||||||
|
|
||||||
var arr = Object.keys(obj);
|
var arr = Object.keys(obj);
|
||||||
|
|
||||||
return arr.hasOwnProperty(0) && arr[0] === "prop";
|
assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true');
|
||||||
}
|
assert.sameValue(arr[0], "prop", 'arr[0]');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,16 +6,13 @@ es5id: 15.2.3.14-5-a-1
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - 'value' attribute of element in returned array is
|
Object.keys - 'value' attribute of element in returned array is
|
||||||
correct.
|
correct.
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: 1 };
|
var obj = { prop1: 1 };
|
||||||
|
|
||||||
var array = Object.keys(obj);
|
var array = Object.keys(obj);
|
||||||
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(array, "0");
|
var desc = Object.getOwnPropertyDescriptor(array, "0");
|
||||||
|
|
||||||
return desc.hasOwnProperty("value") && desc.value === "prop1";
|
assert(desc.hasOwnProperty("value"), 'desc.hasOwnProperty("value") !== true');
|
||||||
}
|
assert.sameValue(desc.value, "prop1", 'desc.value');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-5-a-3
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - 'enumerable' attribute of element of returned array
|
Object.keys - 'enumerable' attribute of element of returned array
|
||||||
is correct
|
is correct
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: 100 };
|
var obj = { prop1: 100 };
|
||||||
|
|
||||||
var array = Object.keys(obj);
|
var array = Object.keys(obj);
|
||||||
@ -21,6 +19,6 @@ function testcase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result && desc.hasOwnProperty("enumerable") && desc.enumerable === true;
|
assert(result, 'result !== true');
|
||||||
}
|
assert(desc.hasOwnProperty("enumerable"), 'desc.hasOwnProperty("enumerable") !== true');
|
||||||
runTestCase(testcase);
|
assert.sameValue(desc.enumerable, true, 'desc.enumerable');
|
||||||
|
@ -6,10 +6,8 @@ es5id: 15.2.3.14-5-a-4
|
|||||||
description: >
|
description: >
|
||||||
Object.keys - Verify that 'configurable' attribute of element of
|
Object.keys - Verify that 'configurable' attribute of element of
|
||||||
returned array is correct
|
returned array is correct
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: 100 };
|
var obj = { prop1: 100 };
|
||||||
|
|
||||||
var array = Object.keys(obj);
|
var array = Object.keys(obj);
|
||||||
@ -17,6 +15,6 @@ function testcase() {
|
|||||||
|
|
||||||
delete array[0];
|
delete array[0];
|
||||||
|
|
||||||
return typeof array[0] === "undefined" && desc.hasOwnProperty("configurable") && desc.configurable === true;
|
assert.sameValue(typeof array[0], "undefined", 'typeof array[0]');
|
||||||
}
|
assert(desc.hasOwnProperty("configurable"), 'desc.hasOwnProperty("configurable") !== true');
|
||||||
runTestCase(testcase);
|
assert.sameValue(desc.configurable, true, 'desc.configurable');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user