mirror of
https://github.com/tc39/test262.git
synced 2025-09-24 10:38:30 +02:00
Prefer verifyProperty over assert.deepEqual when comparing property descriptors
This commit is contained in:
parent
69e5cd3607
commit
5853b56f6e
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,46 +11,50 @@ esid: pending
|
||||
---*/
|
||||
let Array_unscopables = Array.prototype[Symbol.unscopables];
|
||||
|
||||
let desc = Reflect.getOwnPropertyDescriptor(Array.prototype, Symbol.unscopables);
|
||||
assert.deepEqual(desc, {
|
||||
verifyProperty(Array.prototype, Symbol.unscopables, {
|
||||
value: Array_unscopables,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
}, {
|
||||
restore: true
|
||||
});
|
||||
|
||||
assert.sameValue(Reflect.getPrototypeOf(Array_unscopables), null);
|
||||
|
||||
let desc2 = Object.getOwnPropertyDescriptor(Array_unscopables, "values");
|
||||
assert.deepEqual(desc2, {
|
||||
verifyProperty(Array_unscopables, "values", {
|
||||
value: true,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}, {
|
||||
restore: true
|
||||
});
|
||||
|
||||
let keys = Reflect.ownKeys(Array_unscopables);
|
||||
|
||||
// FIXME: Once bug 1826643 is fixed, change this test so that all
|
||||
// the keys are in alphabetical order
|
||||
let expectedKeys = ["at",
|
||||
"copyWithin",
|
||||
"entries",
|
||||
"fill",
|
||||
"find",
|
||||
"findIndex",
|
||||
"findLast",
|
||||
"findLastIndex",
|
||||
"flat",
|
||||
"flatMap",
|
||||
"includes",
|
||||
"keys",
|
||||
"toReversed",
|
||||
"toSorted",
|
||||
"toSpliced",
|
||||
"values"];
|
||||
let expectedKeys = [
|
||||
"at",
|
||||
"copyWithin",
|
||||
"entries",
|
||||
"fill",
|
||||
"find",
|
||||
"findIndex",
|
||||
"findLast",
|
||||
"findLastIndex",
|
||||
"flat",
|
||||
"flatMap",
|
||||
"includes",
|
||||
"keys",
|
||||
"toReversed",
|
||||
"toSorted",
|
||||
"toSpliced",
|
||||
"values"
|
||||
];
|
||||
|
||||
assert.deepEqual(keys, expectedKeys);
|
||||
assert.compareArray(keys, expectedKeys);
|
||||
|
||||
for (let key of keys)
|
||||
assert.sameValue(Array_unscopables[key], true);
|
||||
|
@ -2,19 +2,18 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
var desc = Object.getOwnPropertyDescriptor(Function.prototype, "length");
|
||||
assert.deepEqual(desc,
|
||||
|
||||
verifyProperty(Function.prototype, "length",
|
||||
{value: 0, writable: false, enumerable: false, configurable: true});
|
||||
|
||||
assert.sameValue(Function.prototype.prototype, undefined);
|
||||
assert.sameValue(Function.prototype.callee, undefined);
|
||||
assert.throws(TypeError, () => Function.prototype.caller);
|
||||
assert.throws(TypeError, () => Function.prototype.arguments);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [deepEqual.js]
|
||||
includes: [propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -17,9 +17,8 @@ const ThrowTypeError = function(){
|
||||
return Object.getOwnPropertyDescriptor(arguments, "callee").get;
|
||||
}();
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(ThrowTypeError, "length"), {
|
||||
verifyProperty(ThrowTypeError, "length", {
|
||||
value: 0, writable: false, enumerable: false, configurable: false
|
||||
});
|
||||
|
||||
assert.sameValue(Object.isFrozen(ThrowTypeError), true);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.difference, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.difference, "length"), {
|
||||
verifyProperty(Set.prototype.difference, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.difference, "name"), {
|
||||
verifyProperty(Set.prototype.difference, "name", {
|
||||
value: "difference", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.intersection, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.intersection, "length"), {
|
||||
verifyProperty(Set.prototype.intersection, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.intersection, "name"), {
|
||||
verifyProperty(Set.prototype.intersection, "name", {
|
||||
value: "intersection", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.isDisjointFrom, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.isDisjointFrom, "length"), {
|
||||
verifyProperty(Set.prototype.isDisjointFrom, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.isDisjointFrom, "name"), {
|
||||
verifyProperty(Set.prototype.isDisjointFrom, "name", {
|
||||
value: "isDisjointFrom", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.isSubsetOf, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.isSubsetOf, "length"), {
|
||||
verifyProperty(Set.prototype.isSubsetOf, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.isSubsetOf, "name"), {
|
||||
verifyProperty(Set.prototype.isSubsetOf, "name", {
|
||||
value: "isSubsetOf", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.isSupersetOf, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.isSupersetOf, "length"), {
|
||||
verifyProperty(Set.prototype.isSupersetOf, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.isSupersetOf, "name"), {
|
||||
verifyProperty(Set.prototype.isSupersetOf, "name", {
|
||||
value: "isSupersetOf", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.symmetricDifference, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.symmetricDifference, "length"), {
|
||||
verifyProperty(Set.prototype.symmetricDifference, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.symmetricDifference, "name"), {
|
||||
verifyProperty(Set.prototype.symmetricDifference, "name", {
|
||||
value: "symmetricDifference", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-Set-shell.js, deepEqual.js, compareArray.js]
|
||||
includes: [sm/non262-Set-shell.js, compareArray.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -11,10 +11,10 @@ esid: pending
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set.prototype.union, "function");
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.union, "length"), {
|
||||
verifyProperty(Set.prototype.union, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(Set.prototype.union, "name"), {
|
||||
verifyProperty(Set.prototype.union, "name", {
|
||||
value: "union", writable: false, enumerable: false, configurable: true,
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-TypedArray-shell.js, deepEqual.js]
|
||||
includes: [sm/non262-TypedArray-shell.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -18,13 +18,14 @@ assert.sameValue(typeof TypedArrayPrototype.set, "function");
|
||||
// The concrete TypedArray prototypes do not have an own "set" property.
|
||||
assert.sameValue(anyTypedArrayConstructors.every(c => !c.hasOwnProperty("set")), true);
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(TypedArrayPrototype, "set"), {
|
||||
verifyProperty(TypedArrayPrototype, "set", {
|
||||
value: TypedArrayPrototype.set,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
}, {
|
||||
restore: true
|
||||
});
|
||||
|
||||
assert.sameValue(TypedArrayPrototype.set.name, "set");
|
||||
assert.sameValue(TypedArrayPrototype.set.length, 1);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-TypedArray-shell.js, deepEqual.js]
|
||||
includes: [sm/non262-TypedArray-shell.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -21,11 +21,13 @@ assert.sameValue(TypedArrayPrototype.toLocaleString === Array.prototype.toLocale
|
||||
// The concrete TypedArray prototypes do not have an own "toLocaleString" property.
|
||||
assert.sameValue(anyTypedArrayConstructors.every(c => !c.hasOwnProperty("toLocaleString")), true);
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(TypedArrayPrototype, "toLocaleString"), {
|
||||
verifyProperty(TypedArrayPrototype, "toLocaleString", {
|
||||
value: TypedArrayPrototype.toLocaleString,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
}, {
|
||||
restore: true
|
||||
});
|
||||
|
||||
assert.sameValue(TypedArrayPrototype.toLocaleString.name, "toLocaleString");
|
||||
@ -86,4 +88,3 @@ for (let constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(called, true);
|
||||
}
|
||||
Number.prototype.toLocaleString = originalNumberToLocaleString;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262-TypedArray-shell.js, deepEqual.js]
|
||||
includes: [sm/non262-TypedArray-shell.js, propertyHelper.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
@ -20,11 +20,13 @@ assert.sameValue(TypedArrayPrototype.toString, Array.prototype.toString);
|
||||
// The concrete TypedArray prototypes do not have an own "toString" property.
|
||||
assert.sameValue(anyTypedArrayConstructors.every(c => !c.hasOwnProperty("toString")), true);
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(TypedArrayPrototype, "toString"), {
|
||||
verifyProperty(TypedArrayPrototype, "toString", {
|
||||
value: TypedArrayPrototype.toString,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
}, {
|
||||
restore: true
|
||||
});
|
||||
|
||||
for (let constructor of anyTypedArrayConstructors) {
|
||||
@ -79,4 +81,3 @@ for (let constructor of anyTypedArrayConstructors) {
|
||||
let {array, expected} = testCases[constructor.name];
|
||||
assert.sameValue(new constructor(array).toString(), expected);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user