From 69e5cd36071a7a87750b6901cb71b6ee524df619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 30 Apr 2025 14:16:08 +0200 Subject: [PATCH] Prefer assert.compareArray over assert.deepEqual when comparing arrays --- .../sm/Array/concat-spreadable-primitive.js | 4 +-- test/staging/sm/Array/toSpliced.js | 20 +++++++------- test/staging/sm/Array/with.js | 9 +++---- test/staging/sm/ArrayBuffer/slice-species.js | 26 +++++++++---------- .../sm/Function/bound-non-constructable.js | 7 ++--- test/staging/sm/JSON/parse-with-source.js | 10 +++---- test/staging/sm/Proxy/hasInstance.js | 4 +-- test/staging/sm/Reflect/argumentsList.js | 20 +++++--------- test/staging/sm/Reflect/ownKeys.js | 6 ++--- test/staging/sm/Reflect/propertyKeys.js | 4 +-- test/staging/sm/RegExp/split-flags-on-obj.js | 6 ++--- test/staging/sm/RegExp/split-obj.js | 4 +-- test/staging/sm/String/split-GetMethod.js | 4 +-- test/staging/sm/Symbol/enumeration-order.js | 5 ++-- test/staging/sm/Symbol/enumeration.js | 7 +++-- test/staging/sm/Symbol/for-in-order.js | 9 +++---- test/staging/sm/Symbol/property-accessor.js | 9 +++---- test/staging/sm/Symbol/species.js | 4 +-- .../sm/class/superPropDestructuring.js | 4 +-- test/staging/sm/class/superPropHomeObject.js | 5 ++-- test/staging/sm/generators/objects.js | 5 ++-- test/staging/sm/generators/runtime.js | 13 +++++----- .../staging/sm/object/defineProperty-proxy.js | 4 +-- test/staging/sm/object/freeze-proxy.js | 6 ++--- .../sm/object/getOwnPropertySymbols-proxy.js | 4 +-- .../sm/object/getOwnPropertySymbols.js | 10 +++---- test/staging/sm/object/keys.js | 10 +++---- .../sm/object/preventExtensions-proxy.js | 6 ++--- .../sm/object/property-descriptor-order.js | 9 ++++--- .../sm/object/propertyIsEnumerable-proxy.js | 13 +++++----- test/staging/sm/object/seal-proxy.js | 8 +++--- test/staging/sm/object/toPrimitive.js | 6 ++--- 32 files changed, 125 insertions(+), 136 deletions(-) diff --git a/test/staging/sm/Array/concat-spreadable-primitive.js b/test/staging/sm/Array/concat-spreadable-primitive.js index 28b4e9338a..f570807979 100644 --- a/test/staging/sm/Array/concat-spreadable-primitive.js +++ b/test/staging/sm/Array/concat-spreadable-primitive.js @@ -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; diff --git a/test/staging/sm/Array/toSpliced.js b/test/staging/sm/Array/toSpliced.js index 91ce45291d..d8b040fe96 100644 --- a/test/staging/sm/Array/toSpliced.js +++ b/test/staging/sm/Array/toSpliced.js @@ -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]); diff --git a/test/staging/sm/Array/with.js b/test/staging/sm/Array/with.js index 14887a36a3..a8574ecaa1 100644 --- a/test/staging/sm/Array/with.js +++ b/test/staging/sm/Array/with.js @@ -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]); diff --git a/test/staging/sm/ArrayBuffer/slice-species.js b/test/staging/sm/ArrayBuffer/slice-species.js index 97c445da44..b570f8e714 100644 --- a/test/staging/sm/ArrayBuffer/slice-species.js +++ b/test/staging/sm/ArrayBuffer/slice-species.js @@ -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 diff --git a/test/staging/sm/Function/bound-non-constructable.js b/test/staging/sm/Function/bound-non-constructable.js index e18dc4797f..5d5aa06751 100644 --- a/test/staging/sm/Function/bound-non-constructable.js +++ b/test/staging/sm/Function/bound-non-constructable.js @@ -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(); diff --git a/test/staging/sm/JSON/parse-with-source.js b/test/staging/sm/JSON/parse-with-source.js index ad5674dee5..8dd6e44314 100644 --- a/test/staging/sm/JSON/parse-with-source.js +++ b/test/staging/sm/JSON/parse-with-source.js @@ -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() { diff --git a/test/staging/sm/Proxy/hasInstance.js b/test/staging/sm/Proxy/hasInstance.js index 532a08e073..f654784849 100644 --- a/test/staging/sm/Proxy/hasInstance.js +++ b/test/staging/sm/Proxy/hasInstance.js @@ -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"]); diff --git a/test/staging/sm/Reflect/argumentsList.js b/test/staging/sm/Reflect/argumentsList.js index 38c2b2eede..b285241074 100644 --- a/test/staging/sm/Reflect/argumentsList.js +++ b/test/staging/sm/Reflect/argumentsList.js @@ -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"); } diff --git a/test/staging/sm/Reflect/ownKeys.js b/test/staging/sm/Reflect/ownKeys.js index c076372053..fd1a8807dc 100644 --- a/test/staging/sm/Reflect/ownKeys.js +++ b/test/staging/sm/Reflect/ownKeys.js @@ -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. diff --git a/test/staging/sm/Reflect/propertyKeys.js b/test/staging/sm/Reflect/propertyKeys.js index 88c220b62c..9b4054b337 100644 --- a/test/staging/sm/Reflect/propertyKeys.js +++ b/test/staging/sm/Reflect/propertyKeys.js @@ -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, diff --git a/test/staging/sm/RegExp/split-flags-on-obj.js b/test/staging/sm/RegExp/split-flags-on-obj.js index ef57556307..7289d4c139 100644 --- a/test/staging/sm/RegExp/split-flags-on-obj.js +++ b/test/staging/sm/RegExp/split-flags-on-obj.js @@ -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"]); diff --git a/test/staging/sm/RegExp/split-obj.js b/test/staging/sm/RegExp/split-obj.js index dd4eaa5a7a..075b9c7c34 100644 --- a/test/staging/sm/RegExp/split-obj.js +++ b/test/staging/sm/RegExp/split-obj.js @@ -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"]); diff --git a/test/staging/sm/String/split-GetMethod.js b/test/staging/sm/String/split-GetMethod.js index a427d658ef..73f9ae6441 100644 --- a/test/staging/sm/String/split-GetMethod.js +++ b/test/staging/sm/String/split-GetMethod.js @@ -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, "", {}, []]) { diff --git a/test/staging/sm/Symbol/enumeration-order.js b/test/staging/sm/Symbol/enumeration-order.js index 4690df1401..d39f3d846d 100644 --- a/test/staging/sm/Symbol/enumeration-order.js +++ b/test/staging/sm/Symbol/enumeration-order.js @@ -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, {})); - diff --git a/test/staging/sm/Symbol/enumeration.js b/test/staging/sm/Symbol/enumeration.js index ed7b9a8abd..fb3465a9d5 100644 --- a/test/staging/sm/Symbol/enumeration.js +++ b/test/staging/sm/Symbol/enumeration.js @@ -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"]); diff --git a/test/staging/sm/Symbol/for-in-order.js b/test/staging/sm/Symbol/for-in-order.js index eaa8c8859b..df8a26c8b4 100644 --- a/test/staging/sm/Symbol/for-in-order.js +++ b/test/staging/sm/Symbol/for-in-order.js @@ -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"]); diff --git a/test/staging/sm/Symbol/property-accessor.js b/test/staging/sm/Symbol/property-accessor.js index 0689399741..13c7d2329b 100644 --- a/test/staging/sm/Symbol/property-accessor.js +++ b/test/staging/sm/Symbol/property-accessor.js @@ -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]); diff --git a/test/staging/sm/Symbol/species.js b/test/staging/sm/Symbol/species.js index e08016cc00..8607c0844a 100644 --- a/test/staging/sm/Symbol/species.js +++ b/test/staging/sm/Symbol/species.js @@ -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); diff --git a/test/staging/sm/class/superPropDestructuring.js b/test/staging/sm/class/superPropDestructuring.js index 030836e137..cd547cb0b8 100644 --- a/test/staging/sm/class/superPropDestructuring.js +++ b/test/staging/sm/class/superPropDestructuring.js @@ -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; diff --git a/test/staging/sm/class/superPropHomeObject.js b/test/staging/sm/class/superPropHomeObject.js index 2feeb8d766..814a554845 100644 --- a/test/staging/sm/class/superPropHomeObject.js +++ b/test/staging/sm/class/superPropHomeObject.js @@ -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"]); diff --git a/test/staging/sm/generators/objects.js b/test/staging/sm/generators/objects.js index 5fe20a7b85..f3186a542d 100644 --- a/test/staging/sm/generators/objects.js +++ b/test/staging/sm/generators/objects.js @@ -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 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(); diff --git a/test/staging/sm/generators/runtime.js b/test/staging/sm/generators/runtime.js index d49efcc4c1..acf109eaf7 100644 --- a/test/staging/sm/generators/runtime.js +++ b/test/staging/sm/generators/runtime.js @@ -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 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(); - - diff --git a/test/staging/sm/object/defineProperty-proxy.js b/test/staging/sm/object/defineProperty-proxy.js index 83d0402dd9..f06c8e5bce 100644 --- a/test/staging/sm/object/defineProperty-proxy.js +++ b/test/staging/sm/object/defineProperty-proxy.js @@ -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", diff --git a/test/staging/sm/object/freeze-proxy.js b/test/staging/sm/object/freeze-proxy.js index 63839a073a..e9386e43ce 100644 --- a/test/staging/sm/object/freeze-proxy.js +++ b/test/staging/sm/object/freeze-proxy.js @@ -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"]); diff --git a/test/staging/sm/object/getOwnPropertySymbols-proxy.js b/test/staging/sm/object/getOwnPropertySymbols-proxy.js index c993fd2314..addb8323e2 100644 --- a/test/staging/sm/object/getOwnPropertySymbols-proxy.js +++ b/test/staging/sm/object/getOwnPropertySymbols-proxy.js @@ -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); diff --git a/test/staging/sm/object/getOwnPropertySymbols.js b/test/staging/sm/object/getOwnPropertySymbols.js index 7bcc04dbab..43f20256a0 100644 --- a/test/staging/sm/object/getOwnPropertySymbols.js +++ b/test/staging/sm/object/getOwnPropertySymbols.js @@ -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); - diff --git a/test/staging/sm/object/keys.js b/test/staging/sm/object/keys.js index b5ce6aae79..f6c13f8da8 100644 --- a/test/staging/sm/object/keys.js +++ b/test/staging/sm/object/keys.js @@ -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"]); diff --git a/test/staging/sm/object/preventExtensions-proxy.js b/test/staging/sm/object/preventExtensions-proxy.js index 64807160ad..c8a6e550bc 100644 --- a/test/staging/sm/object/preventExtensions-proxy.js +++ b/test/staging/sm/object/preventExtensions-proxy.js @@ -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"]); diff --git a/test/staging/sm/object/property-descriptor-order.js b/test/staging/sm/object/property-descriptor-order.js index 71291ab473..589c1e7f34 100644 --- a/test/staging/sm/object/property-descriptor-order.js +++ b/test/staging/sm/object/property-descriptor-order.js @@ -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; } }); diff --git a/test/staging/sm/object/propertyIsEnumerable-proxy.js b/test/staging/sm/object/propertyIsEnumerable-proxy.js index 41f4d2f50e..4d8b27cc52 100644 --- a/test/staging/sm/object/propertyIsEnumerable-proxy.js +++ b/test/staging/sm/object/propertyIsEnumerable-proxy.js @@ -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, []); } - diff --git a/test/staging/sm/object/seal-proxy.js b/test/staging/sm/object/seal-proxy.js index c3fa85cbc7..0f6e13d3b1 100644 --- a/test/staging/sm/object/seal-proxy.js +++ b/test/staging/sm/object/seal-proxy.js @@ -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"]); diff --git a/test/staging/sm/object/toPrimitive.js b/test/staging/sm/object/toPrimitive.js index 483c452443..ed73eb843b 100644 --- a/test/staging/sm/object/toPrimitive.js +++ b/test/staging/sm/object/toPrimitive.js @@ -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"]);