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