mirror of
https://github.com/tc39/test262.git
synced 2025-09-24 02:28:05 +02:00
Prefer assert.compareArray over assert.deepEqual when comparing arrays
This commit is contained in:
parent
bc544479c8
commit
69e5cd3607
@ -6,7 +6,7 @@
|
||||
/*---
|
||||
flags:
|
||||
- onlyStrict
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
@ -34,7 +34,7 @@ for (let value of primitives) {
|
||||
});
|
||||
|
||||
let x = [1, 2].concat(value);
|
||||
assert.deepEqual(x, [1, 2, value]);
|
||||
assert.compareArray(x, [1, 2, value]);
|
||||
|
||||
delete prototype[Symbol.isConcatSpreadable];
|
||||
delete prototype.length;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -22,14 +22,14 @@ Object.defineProperty(Array.prototype, 1, {
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual([].toSpliced(0, 0, 1), [1]);
|
||||
assert.compareArray([].toSpliced(0, 0, 1), [1]);
|
||||
|
||||
assert.deepEqual([0].toSpliced(0, 0, 0), [0, 0]);
|
||||
assert.deepEqual([0].toSpliced(0, 0, 1), [1, 0]);
|
||||
assert.deepEqual([0].toSpliced(0, 1, 0), [0]);
|
||||
assert.deepEqual([0].toSpliced(0, 1, 1), [1]);
|
||||
assert.deepEqual([0].toSpliced(1, 0, 0), [0, 0]);
|
||||
assert.deepEqual([0].toSpliced(1, 0, 1), [0, 1]);
|
||||
assert.deepEqual([0].toSpliced(1, 1, 0), [0, 0]);
|
||||
assert.deepEqual([0].toSpliced(1, 1, 1), [0, 1]);
|
||||
assert.compareArray([0].toSpliced(0, 0, 0), [0, 0]);
|
||||
assert.compareArray([0].toSpliced(0, 0, 1), [1, 0]);
|
||||
assert.compareArray([0].toSpliced(0, 1, 0), [0]);
|
||||
assert.compareArray([0].toSpliced(0, 1, 1), [1]);
|
||||
assert.compareArray([0].toSpliced(1, 0, 0), [0, 0]);
|
||||
assert.compareArray([0].toSpliced(1, 0, 1), [0, 1]);
|
||||
assert.compareArray([0].toSpliced(1, 1, 0), [0, 0]);
|
||||
assert.compareArray([0].toSpliced(1, 1, 1), [0, 1]);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -17,9 +17,8 @@ Object.defineProperty(Array.prototype, 0, {
|
||||
});
|
||||
|
||||
// Single element case.
|
||||
assert.deepEqual([0].with(0, 1), [1]);
|
||||
assert.compareArray([0].with(0, 1), [1]);
|
||||
|
||||
// More than one element.
|
||||
assert.deepEqual([1, 2].with(0, 3), [3, 2]);
|
||||
assert.deepEqual([1, 2].with(1, 3), [1, 3]);
|
||||
|
||||
assert.compareArray([1, 2].with(0, 3), [3, 2]);
|
||||
assert.compareArray([1, 2].with(1, 3), [1, 3]);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -58,8 +58,8 @@ for (let [ctor, answer] of tests) {
|
||||
logs.length = 0;
|
||||
let buf = arr.buffer.slice(8, 16);
|
||||
assert.sameValue(buf.constructor, MyArrayBuffer);
|
||||
assert.deepEqual(logs, ["get @@species", "get ctor.prototype", "call ctor"]);
|
||||
assert.deepEqual([...new ctor(buf)], answer);
|
||||
assert.compareArray(logs, ["get @@species", "get ctor.prototype", "call ctor"]);
|
||||
assert.compareArray([...new ctor(buf)], answer);
|
||||
|
||||
|
||||
// modified @@species
|
||||
@ -69,7 +69,7 @@ for (let [ctor, answer] of tests) {
|
||||
};
|
||||
let b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, MyArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
class MyArrayBufferWithSpecies extends ArrayBuffer {
|
||||
get [Symbol.species]() {
|
||||
@ -80,7 +80,7 @@ for (let [ctor, answer] of tests) {
|
||||
a.constructor = MyArrayBufferWithSpecies;
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, MyArrayBufferWithSpecies);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
// no @@species
|
||||
a = arr.buffer;
|
||||
@ -89,7 +89,7 @@ for (let [ctor, answer] of tests) {
|
||||
};
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, ArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
a = arr.buffer;
|
||||
a.constructor = {
|
||||
@ -97,7 +97,7 @@ for (let [ctor, answer] of tests) {
|
||||
};
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, ArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
// invalid @@species
|
||||
for (let species of [0, 1.1, true, false, "a", /a/, Symbol.iterator, [], {}]) {
|
||||
@ -113,7 +113,7 @@ for (let [ctor, answer] of tests) {
|
||||
a.constructor = undefined;
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, ArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
// invalid constructor
|
||||
for (let ctor of [null, 0, 1.1, true, false, "a", Symbol.iterator]) {
|
||||
@ -131,7 +131,7 @@ for (let [ctor, answer] of tests) {
|
||||
};
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, g.MyArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
a = arr.buffer;
|
||||
a.constructor = {
|
||||
@ -139,7 +139,7 @@ for (let [ctor, answer] of tests) {
|
||||
};
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, g.ArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
// constructor from different global
|
||||
g.eval(`
|
||||
@ -153,7 +153,7 @@ var MyArrayBufferWithSpecies = class MyArrayBufferWithSpecies extends ArrayBuffe
|
||||
a.constructor = g.MyArrayBufferWithSpecies;
|
||||
b = a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, g.MyArrayBufferWithSpecies);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
g.eval(`
|
||||
var arr = new ${ctor.name}([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
|
||||
@ -161,12 +161,12 @@ var a = arr.buffer;
|
||||
`);
|
||||
b = ArrayBuffer.prototype.slice.call(g.a, 8, 16);
|
||||
assert.sameValue(b.constructor, g.ArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
// running in different global
|
||||
b = g.a.slice(8, 16);
|
||||
assert.sameValue(b.constructor, g.ArrayBuffer);
|
||||
assert.deepEqual([...new ctor(b)], answer);
|
||||
assert.compareArray([...new ctor(b)], answer);
|
||||
|
||||
// subclasses
|
||||
// not-modified @@species
|
||||
|
@ -2,13 +2,14 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var objects = [
|
||||
Math.sin.bind(null),
|
||||
new Proxy(Math.sin.bind(null), {}),
|
||||
@ -17,8 +18,8 @@ var objects = [
|
||||
|
||||
for (var obj of objects) {
|
||||
// Target is not constructable, so a new array should be created internally.
|
||||
assert.deepEqual(Array.from.call(obj, [1, 2, 3]), [1, 2, 3]);
|
||||
assert.deepEqual(Array.of.call(obj, 1, 2, 3), [1, 2, 3]);
|
||||
assert.compareArray(Array.from.call(obj, [1, 2, 3]), [1, 2, 3]);
|
||||
assert.compareArray(Array.of.call(obj, 1, 2, 3), [1, 2, 3]);
|
||||
|
||||
// Make sure they are callable, but not constructable.
|
||||
obj();
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [compareArray.js, deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -95,9 +95,9 @@ esid: pending
|
||||
function assertIsRawJson(rawJson, expectedRawJsonValue) {
|
||||
assert.sameValue(null, Object.getPrototypeOf(rawJson));
|
||||
assert.sameValue(true, Object.hasOwn(rawJson, 'rawJSON'));
|
||||
assert.deepEqual(['rawJSON'], Object.keys(rawJson));
|
||||
assert.deepEqual(['rawJSON'], Object.getOwnPropertyNames(rawJson));
|
||||
assert.deepEqual([], Object.getOwnPropertySymbols(rawJson));
|
||||
assert.compareArray(['rawJSON'], Object.keys(rawJson));
|
||||
assert.compareArray(['rawJSON'], Object.getOwnPropertyNames(rawJson));
|
||||
assert.compareArray([], Object.getOwnPropertySymbols(rawJson));
|
||||
assert.sameValue(expectedRawJsonValue, rawJson.rawJSON);
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ esid: pending
|
||||
var p = JSON.rawJSON(false);
|
||||
var obj = { a: "hi" };
|
||||
Object.setPrototypeOf(obj, p);
|
||||
assert.deepEqual(obj.rawJSON, "false");
|
||||
assert.sameValue(obj.rawJSON, "false");
|
||||
})();
|
||||
|
||||
(function checkErrorsComeFromCorrectRealm() {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -19,5 +19,5 @@ var p = new Proxy(fun, {
|
||||
});
|
||||
|
||||
assert.sameValue(new fun instanceof p, true);
|
||||
assert.deepEqual(get, [Symbol.hasInstance, "prototype"]);
|
||||
assert.compareArray(get, [Symbol.hasInstance, "prototype"]);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-shell.js, sm/non262-Reflect-shell.js, deepEqual.js]
|
||||
includes: [sm/non262-shell.js, sm/non262-Reflect-shell.js, compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -66,14 +66,10 @@ function getArgs(...args) {
|
||||
return args;
|
||||
}
|
||||
for (var method of BOTH) {
|
||||
assert.deepEqual(method(getArgs, undefined, {length: 0}),
|
||||
[]);
|
||||
assert.deepEqual(method(getArgs, undefined, {length: 1, "0": "zero"}),
|
||||
["zero"]);
|
||||
assert.deepEqual(method(getArgs, undefined, {length: 2}),
|
||||
[undefined, undefined]);
|
||||
assert.deepEqual(method(getArgs, undefined, function (a, b, c) {}),
|
||||
[undefined, undefined, undefined]);
|
||||
assert.compareArray(method(getArgs, undefined, {length: 0}), []);
|
||||
assert.compareArray(method(getArgs, undefined, {length: 1, "0": "zero"}), ["zero"]);
|
||||
assert.compareArray(method(getArgs, undefined, {length: 2}), [undefined, undefined]);
|
||||
assert.compareArray(method(getArgs, undefined, function (a, b, c) {}), [undefined, undefined, undefined]);
|
||||
}
|
||||
|
||||
// The Iterable/Iterator interfaces are not used.
|
||||
@ -85,8 +81,7 @@ var funnyArgs = {
|
||||
next() { throw "FAIL 2"; }
|
||||
};
|
||||
for (var method of BOTH) {
|
||||
assert.deepEqual(method(getArgs, undefined, funnyArgs),
|
||||
["zero", "one"]);
|
||||
assert.compareArray(method(getArgs, undefined, funnyArgs), ["zero", "one"]);
|
||||
}
|
||||
|
||||
// If argumentList has no .length property, no arguments are passed.
|
||||
@ -108,8 +103,7 @@ args = {
|
||||
};
|
||||
for (var method of BOTH) {
|
||||
log = "";
|
||||
assert.deepEqual(method(getArgs, undefined, args),
|
||||
["zero"]);
|
||||
assert.compareArray(method(getArgs, undefined, args), ["zero"]);
|
||||
assert.sameValue(log, "L0");
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -44,7 +44,7 @@ var cases = [
|
||||
keys: Reflect.ownKeys(Math)}
|
||||
];
|
||||
for (var {object, keys} of cases)
|
||||
assert.deepEqual(Reflect.ownKeys(object), keys);
|
||||
assert.compareArray(Reflect.ownKeys(object), keys);
|
||||
|
||||
// Reflect.ownKeys() creates a new array each time it is called.
|
||||
var object = {}, keys = [];
|
||||
@ -61,7 +61,7 @@ proxy = new Proxy(obj, {
|
||||
ownKeys() { return keys; }
|
||||
});
|
||||
var actual = Reflect.ownKeys(proxy);
|
||||
assert.deepEqual(actual, keys); // we get correct answers
|
||||
assert.compareArray(actual, keys); // we get correct answers
|
||||
assert.sameValue(actual !== keys, true); // but not the same object
|
||||
|
||||
// If a proxy breaks invariants, a TypeError is thrown.
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-shell.js, deepEqual.js]
|
||||
includes: [sm/non262-shell.js, compareArray.js, deepEqual.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -69,7 +69,7 @@ for (var {value, expected} of keys) {
|
||||
|
||||
var obj = {};
|
||||
assert.sameValue(Reflect.defineProperty(obj, value, {value: 1, configurable: true}), true);
|
||||
assert.deepEqual(Reflect.ownKeys(obj), [expected]);
|
||||
assert.compareArray(Reflect.ownKeys(obj), [expected]);
|
||||
assert.deepEqual(Reflect.getOwnPropertyDescriptor(obj, value),
|
||||
{value: 1,
|
||||
writable: false,
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -15,11 +15,11 @@ delete RegExp.prototype.flags;
|
||||
|
||||
let re = /a/i;
|
||||
let a = re[Symbol.split]("1a2A3a4A5");
|
||||
assert.deepEqual(a, ["1", "2", "3", "4", "5"]);
|
||||
assert.compareArray(a, ["1", "2", "3", "4", "5"]);
|
||||
|
||||
delete Object.prototype.flags;
|
||||
|
||||
Object.prototype.flags = "";
|
||||
|
||||
a = re[Symbol.split]("1a2A3a4A5");
|
||||
assert.deepEqual(a, ["1", "2A3", "4A5"]);
|
||||
assert.compareArray(a, ["1", "2A3", "4A5"]);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,5 +11,5 @@ esid: pending
|
||||
---*/
|
||||
|
||||
var obj = { flags: "", toString: () => "-" };
|
||||
assert.deepEqual(RegExp.prototype[Symbol.split].call(obj, "a-b-c"),
|
||||
assert.compareArray(RegExp.prototype[Symbol.split].call(obj, "a-b-c"),
|
||||
["a", "b", "c"]);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -20,7 +20,7 @@ function create(value) {
|
||||
}
|
||||
|
||||
for (let v of [null, undefined]) {
|
||||
assert.deepEqual("a-a".split(create(v)), ["a", "a"]);
|
||||
assert.compareArray("a-a".split(create(v)), ["a", "a"]);
|
||||
}
|
||||
|
||||
for (let v of [1, true, Symbol.iterator, "", {}, []]) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -38,11 +38,10 @@ function test(descsObj) {
|
||||
log = [];
|
||||
Object.defineProperties(LoggingProxy(), descs);
|
||||
assert.sameValue(log.length, keys.length);
|
||||
assert.deepEqual(log.map(k => typeof k), ["string", "string", "string", "symbol", "symbol", "symbol"]);
|
||||
assert.compareArray(log.map(k => typeof k), ["string", "string", "string", "symbol", "symbol", "symbol"]);
|
||||
for (var key of keys)
|
||||
assert.sameValue(log.indexOf(key) !== -1, true);
|
||||
}
|
||||
|
||||
test(descs);
|
||||
test(new Proxy(descs, {}));
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -55,6 +55,5 @@ var h = {
|
||||
}
|
||||
};
|
||||
p = new Proxy({}, h);
|
||||
assert.deepEqual(Object.keys(p), ["a", "0"]);
|
||||
assert.deepEqual(log, ["ownKeys", "gopd", "a", "gopd", "0"]);
|
||||
|
||||
assert.compareArray(Object.keys(p), ["a", "0"]);
|
||||
assert.compareArray(log, ["ownKeys", "gopd", "a", "gopd", "0"]);
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -27,8 +27,8 @@ Object.prototype[Symbol.for("comet")] = 6;
|
||||
var keys = [];
|
||||
for (var k in obj)
|
||||
keys.push(k);
|
||||
assert.deepEqual(keys, ["x", "y", "z"]);
|
||||
assert.deepEqual(Object.keys(obj), ["x", "y", "z"]);
|
||||
assert.compareArray(keys, ["x", "y", "z"]);
|
||||
assert.compareArray(Object.keys(obj), ["x", "y", "z"]);
|
||||
|
||||
// Test with more properties.
|
||||
for (var i = 0; i < 1000; i++)
|
||||
@ -37,5 +37,4 @@ obj.w = 1000;
|
||||
keys = []
|
||||
for (var k in obj)
|
||||
keys.push(k);
|
||||
assert.deepEqual(keys, ["x", "y", "z", "w"]);
|
||||
|
||||
assert.compareArray(keys, ["x", "y", "z", "w"]);
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -31,17 +31,16 @@ for (var i = 0; i < 9; i++) {
|
||||
assert.sameValue(obj[sym] = i, i);
|
||||
expected.push(i);
|
||||
}
|
||||
assert.deepEqual(sets, expected);
|
||||
assert.compareArray(sets, expected);
|
||||
|
||||
// increment operator
|
||||
gets = 0;
|
||||
sets = [];
|
||||
assert.sameValue(obj[sym]++, 1);
|
||||
assert.deepEqual(sets, [2]);
|
||||
assert.compareArray(sets, [2]);
|
||||
|
||||
// assignment
|
||||
gets = 0;
|
||||
sets = [];
|
||||
assert.sameValue(obj[sym] *= 12, 12);
|
||||
assert.deepEqual(sets, [12]);
|
||||
|
||||
assert.compareArray(sets, [12]);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -24,7 +24,7 @@ for (C of [Array, Map, Set, RegExp,
|
||||
TypedArray,
|
||||
ArrayBuffer]) {
|
||||
var desc = Object.getOwnPropertyDescriptor(C, Symbol.species);
|
||||
assert.deepEqual(Object.keys(desc).sort(), ["configurable", "enumerable", "get", "set"]);
|
||||
assert.compareArray(Object.keys(desc).sort(), ["configurable", "enumerable", "get", "set"]);
|
||||
assert.sameValue(desc.set, undefined);
|
||||
assert.sameValue(desc.enumerable, false);
|
||||
assert.sameValue(desc.configurable, true);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -33,7 +33,7 @@ const testArr = [525600, "Fred"];
|
||||
class derived extends base {
|
||||
constructor() { super(); }
|
||||
prepForTest() { seenValues = []; }
|
||||
testAsserts() { assert.deepEqual(seenValues, testArr); }
|
||||
testAsserts() { assert.compareArray(seenValues, testArr); }
|
||||
testProps() {
|
||||
this.prepForTest();
|
||||
[super.minutes, super.intendent] = testArr;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -66,5 +66,4 @@ for (let exprBase of [base1, base2])
|
||||
constructor() { super(); }
|
||||
test() { animals.push(super["test"]()); }
|
||||
}().test();
|
||||
assert.deepEqual(animals, ["llama", "alpaca"]);
|
||||
|
||||
assert.compareArray(animals, ["llama", "alpaca"]);
|
||||
|
@ -2,13 +2,14 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
// This file was written by Andy Wingo <wingo@igalia.com> and originally
|
||||
// contributed to V8 as generators-objects.js, available here:
|
||||
//
|
||||
@ -24,7 +25,7 @@ function TestGeneratorObject() {
|
||||
assert.sameValue(Object.getPrototypeOf(iter), g.prototype);
|
||||
assert.sameValue(iter instanceof g, true);
|
||||
assert.sameValue(String(iter), "[object Generator]");
|
||||
assert.deepEqual(Object.getOwnPropertyNames(iter), []);
|
||||
assert.compareArray(Object.getOwnPropertyNames(iter), []);
|
||||
assert.notSameValue(g(), iter);
|
||||
}
|
||||
TestGeneratorObject();
|
||||
|
@ -2,13 +2,14 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
// This file was written by Andy Wingo <wingo@igalia.com> and originally
|
||||
// contributed to V8 as generators-runtime.js, available here:
|
||||
//
|
||||
@ -39,7 +40,7 @@ function TestGeneratorFunctionInstance() {
|
||||
f_own_property_names.sort();
|
||||
g_own_property_names.sort();
|
||||
|
||||
assert.deepEqual(f_own_property_names, g_own_property_names);
|
||||
assert.compareArray(f_own_property_names, g_own_property_names);
|
||||
var i;
|
||||
for (i = 0; i < f_own_property_names.length; i++) {
|
||||
var prop = f_own_property_names[i];
|
||||
@ -84,8 +85,8 @@ function TestGeneratorObjectPrototype() {
|
||||
expected_property_names.sort();
|
||||
found_property_names.sort();
|
||||
|
||||
assert.deepEqual(found_property_names, expected_property_names);
|
||||
assert.deepEqual(Object.getOwnPropertySymbols(GeneratorObjectPrototype), [Symbol.toStringTag]);
|
||||
assert.compareArray(found_property_names, expected_property_names);
|
||||
assert.compareArray(Object.getOwnPropertySymbols(GeneratorObjectPrototype), [Symbol.toStringTag]);
|
||||
}
|
||||
TestGeneratorObjectPrototype();
|
||||
|
||||
@ -134,8 +135,6 @@ function TestPerGeneratorPrototype() {
|
||||
assert.sameValue(g.prototype instanceof Function, false);
|
||||
assert.sameValue(typeof (g.prototype), "object");
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertyNames(g.prototype), []);
|
||||
assert.compareArray(Object.getOwnPropertyNames(g.prototype), []);
|
||||
}
|
||||
TestPerGeneratorPrototype();
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -51,7 +51,7 @@ for (var obj of testSubjects) {
|
||||
|
||||
// It should have performed exactly these operations on the proxy, in this
|
||||
// order. See ES6 rev 24 (2014 April 27) 6.2.4.5 ToPropertyDescriptor.
|
||||
assert.deepEqual(log, [
|
||||
assert.compareArray(log, [
|
||||
"has enumerable", "get enumerable",
|
||||
"has configurable", "get configurable",
|
||||
"has value", "get value",
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -29,9 +29,9 @@ function logProxy(object = {}, handler = {}) {
|
||||
|
||||
var {proxy, log} = logProxy();
|
||||
Object.freeze(proxy);
|
||||
assert.deepEqual(log, ["preventExtensions", "ownKeys"]);
|
||||
assert.compareArray(log, ["preventExtensions", "ownKeys"]);
|
||||
|
||||
var {proxy, log} = logProxy();
|
||||
Object.freeze(Object.freeze(proxy));
|
||||
assert.deepEqual(log, ["preventExtensions", "ownKeys", "preventExtensions", "ownKeys"]);
|
||||
assert.compareArray(log, ["preventExtensions", "ownKeys", "preventExtensions", "ownKeys"]);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -31,6 +31,6 @@ function OwnKeysProxy() {
|
||||
return new Proxy({}, new HandlerProxy);
|
||||
}
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertySymbols(new OwnKeysProxy), symbols);
|
||||
assert.compareArray(Object.getOwnPropertySymbols(new OwnKeysProxy), symbols);
|
||||
assert.sameValue(hits, 1);
|
||||
|
||||
|
@ -4,14 +4,15 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
assert.deepEqual(Object.getOwnPropertySymbols({}), []);
|
||||
|
||||
assert.compareArray(Object.getOwnPropertySymbols({}), []);
|
||||
|
||||
// String keys are ignored.
|
||||
assert.sameValue(Object.getOwnPropertySymbols({a: 1, b: 2}).length, 0);
|
||||
@ -22,8 +23,8 @@ var iterable = {};
|
||||
Object.defineProperty(iterable, Symbol.iterator, {
|
||||
value: () => [][Symbol.iterator]()
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertySymbols(iterable), [Symbol.iterator]);
|
||||
assert.deepEqual(Object.getOwnPropertySymbols(new Proxy(iterable, {})), [Symbol.iterator]);
|
||||
assert.compareArray(Object.getOwnPropertySymbols(iterable), [Symbol.iterator]);
|
||||
assert.compareArray(Object.getOwnPropertySymbols(new Proxy(iterable, {})), [Symbol.iterator]);
|
||||
|
||||
// Test on an object with a thousand own properties.
|
||||
var obj = {};
|
||||
@ -51,4 +52,3 @@ for (var primitive of [true, 1, 3.14, "hello", Symbol()])
|
||||
assert.sameValue(Object.getOwnPropertySymbols(primitive).length, 0);
|
||||
|
||||
assert.sameValue(Object.getOwnPropertySymbols.length, 1);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -16,10 +16,10 @@ assert.throws(TypeError, () => Object.keys());
|
||||
assert.throws(TypeError, () => Object.keys(undefined));
|
||||
assert.throws(TypeError, () => Object.keys(null));
|
||||
|
||||
assert.deepEqual(Object.keys(1), []);
|
||||
assert.deepEqual(Object.keys(true), []);
|
||||
assert.compareArray(Object.keys(1), []);
|
||||
assert.compareArray(Object.keys(true), []);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.deepEqual(Object.keys(Symbol("foo")), []);
|
||||
assert.compareArray(Object.keys(Symbol("foo")), []);
|
||||
}
|
||||
|
||||
assert.deepEqual(Object.keys("foo"), ["0", "1", "2"]);
|
||||
assert.compareArray(Object.keys("foo"), ["0", "1", "2"]);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -25,9 +25,9 @@ function logProxy(object = {}, handler = {}) {
|
||||
|
||||
var {proxy, log} = logProxy();
|
||||
Object.preventExtensions(proxy);
|
||||
assert.deepEqual(log, ["preventExtensions"]);
|
||||
assert.compareArray(log, ["preventExtensions"]);
|
||||
|
||||
var {proxy, log} = logProxy();
|
||||
Object.preventExtensions(Object.preventExtensions(proxy));
|
||||
assert.deepEqual(log, ["preventExtensions", "preventExtensions"]);
|
||||
assert.compareArray(log, ["preventExtensions", "preventExtensions"]);
|
||||
|
||||
|
@ -2,23 +2,24 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var names = Object.getOwnPropertyNames(Object.getOwnPropertyDescriptor({foo: 0}, "foo"));
|
||||
assert.deepEqual(names, ["value", "writable", "enumerable", "configurable"]);
|
||||
assert.compareArray(names, ["value", "writable", "enumerable", "configurable"]);
|
||||
|
||||
names = Object.getOwnPropertyNames(Object.getOwnPropertyDescriptor({get foo(){}}, "foo"));
|
||||
assert.deepEqual(names, ["get", "set", "enumerable", "configurable"]);
|
||||
assert.compareArray(names, ["get", "set", "enumerable", "configurable"]);
|
||||
|
||||
var proxy = new Proxy({}, {
|
||||
defineProperty(target, key, desc) {
|
||||
var names = Object.getOwnPropertyNames(desc);
|
||||
assert.deepEqual(names, ["set", "configurable"]);
|
||||
assert.compareArray(names, ["set", "configurable"]);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -40,30 +40,29 @@ for (var property of properties) {
|
||||
var {proxy, log} = logProxy({});
|
||||
var result = Object.prototype.propertyIsEnumerable.call(proxy, property);
|
||||
assert.sameValue(result, false);
|
||||
assert.deepEqual(log, [property]);
|
||||
assert.compareArray(log, [property]);
|
||||
|
||||
// Test 2: property is present on object and enumerable
|
||||
var {proxy, log} = logProxy({[property]: 0});
|
||||
var result = Object.prototype.propertyIsEnumerable.call(proxy, property);
|
||||
assert.sameValue(result, true);
|
||||
assert.deepEqual(log, [property]);
|
||||
assert.compareArray(log, [property]);
|
||||
|
||||
// Test 3: property is present on object, but not enumerable
|
||||
var {proxy, log} = logProxy(Object.defineProperty({[property]: 0}, property, {enumerable: false}));
|
||||
var result = Object.prototype.propertyIsEnumerable.call(proxy, property);
|
||||
assert.sameValue(result, false);
|
||||
assert.deepEqual(log, [property]);
|
||||
assert.compareArray(log, [property]);
|
||||
|
||||
// Test 4: property is present on prototype object
|
||||
var {proxy, log} = logProxy(Object.create({[property]: 0}));
|
||||
var result = Object.prototype.propertyIsEnumerable.call(proxy, property);
|
||||
assert.sameValue(result, false);
|
||||
assert.deepEqual(log, [property]);
|
||||
assert.compareArray(log, [property]);
|
||||
|
||||
// Test 5: property is present on prototype object, prototype is proxy object
|
||||
var {proxy, log} = logProxy({[property]: 0});
|
||||
var result = Object.prototype.propertyIsEnumerable.call(Object.create(proxy), property);
|
||||
assert.sameValue(result, false);
|
||||
assert.deepEqual(log, []);
|
||||
assert.compareArray(log, []);
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
@ -29,9 +30,8 @@ function logProxy(object = {}, handler = {}) {
|
||||
|
||||
var {proxy, log} = logProxy();
|
||||
Object.seal(proxy);
|
||||
assert.deepEqual(log, ["preventExtensions", "ownKeys"]);
|
||||
assert.compareArray(log, ["preventExtensions", "ownKeys"]);
|
||||
|
||||
var {proxy, log} = logProxy();
|
||||
Object.seal(Object.seal(proxy));
|
||||
assert.deepEqual(log, ["preventExtensions", "ownKeys", "preventExtensions", "ownKeys"]);
|
||||
|
||||
assert.compareArray(log, ["preventExtensions", "ownKeys", "preventExtensions", "ownKeys"]);
|
||||
|
@ -2,13 +2,14 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
// ES6 7.1.1 ToPrimitive(input [, PreferredType]) specifies a new extension
|
||||
// point in the language. Objects can override the behavior of ToPrimitive
|
||||
// somewhat by supporting the method obj[@@toPrimitive](hint).
|
||||
@ -107,5 +108,4 @@ var handler = new Proxy({}, {
|
||||
});
|
||||
proxy = new Proxy(Object.create(null), handler);
|
||||
assert.throws(TypeError, () => proxy == 0);
|
||||
assert.deepEqual(log, [Symbol.toPrimitive, "valueOf", "toString"]);
|
||||
|
||||
assert.compareArray(log, [Symbol.toPrimitive, "valueOf", "toString"]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user