mirror of
https://github.com/tc39/test262.git
synced 2025-09-25 11:08:49 +02:00
Replace runtime checks for Symbol with feature tag
This commit is contained in:
parent
c35a9c74ba
commit
193801b9d4
@ -10,6 +10,7 @@ flags:
|
||||
description: |
|
||||
Implement %TypedArray%.prototype.{find, findIndex}
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
const methods = ["find", "findIndex"];
|
||||
@ -27,9 +28,7 @@ anyTypedArrayConstructors.forEach(constructor => {
|
||||
assert.sameValue(arr[method](v => v === 3), 3);
|
||||
assert.sameValue(arr[method](v => v === 6), method === "find" ? undefined : -1);
|
||||
|
||||
var thisValues = [undefined, null, true, 1, "foo", [], {}];
|
||||
if (typeof Symbol == "function")
|
||||
thisValues.push(Symbol());
|
||||
var thisValues = [undefined, null, true, 1, "foo", [], {}, Symbol()];
|
||||
|
||||
thisValues.forEach(thisArg =>
|
||||
assert.throws(TypeError, () => arr[method].call(thisArg, () => true))
|
||||
|
@ -10,6 +10,7 @@ flags:
|
||||
description: |
|
||||
Implement %TypedArray%.prototype.{findLast, findLastIndex}
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
const methods = ["findLast", "findLastIndex"];
|
||||
@ -27,9 +28,7 @@ anyTypedArrayConstructors.forEach(constructor => {
|
||||
assert.sameValue(arr[method](v => v === 3), 3);
|
||||
assert.sameValue(arr[method](v => v === 6), method === "findLast" ? undefined : -1);
|
||||
|
||||
var thisValues = [undefined, null, true, 1, "foo", [], {}];
|
||||
if (typeof Symbol == "function")
|
||||
thisValues.push(Symbol());
|
||||
var thisValues = [undefined, null, true, 1, "foo", [], {}, Symbol()];
|
||||
|
||||
thisValues.forEach(thisArg =>
|
||||
assert.throws(TypeError, () => arr[method].call(thisArg, () => true))
|
||||
|
@ -10,7 +10,9 @@ flags:
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
if ("entries" in Object) {
|
||||
assert.sameValue(Object.entries.length, 1);
|
||||
|
||||
@ -65,8 +67,7 @@ if ("entries" in Object) {
|
||||
|
||||
assert.deepEqual(Object.entries(1), []);
|
||||
assert.deepEqual(Object.entries(true), []);
|
||||
if (typeof Symbol === "function")
|
||||
assert.deepEqual(Object.entries(Symbol("foo")), []);
|
||||
assert.deepEqual(Object.entries(Symbol("foo")), []);
|
||||
|
||||
assert.deepEqual(Object.entries("foo"), [["0", "f"], ["1", "o"], ["2", "o"]]);
|
||||
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Object.freeze() should return its argument with no conversion when the argument is a primitive value
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.freeze(), undefined);
|
||||
@ -17,7 +18,4 @@ assert.sameValue(Object.freeze(null), null);
|
||||
assert.sameValue(Object.freeze(1), 1);
|
||||
assert.sameValue(Object.freeze("foo"), "foo");
|
||||
assert.sameValue(Object.freeze(true), true);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.freeze(Symbol.for("foo")), Symbol.for("foo"));
|
||||
}
|
||||
|
||||
assert.sameValue(Object.freeze(Symbol.for("foo")), Symbol.for("foo"));
|
||||
|
@ -10,6 +10,7 @@ flags:
|
||||
description: |
|
||||
Coerce the argument passed to Object.getOwnPropertyDescriptor using ToObject
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => Object.getOwnPropertyDescriptor());
|
||||
@ -18,9 +19,7 @@ assert.throws(TypeError, () => Object.getOwnPropertyDescriptor(null));
|
||||
|
||||
Object.getOwnPropertyDescriptor(1);
|
||||
Object.getOwnPropertyDescriptor(true);
|
||||
if (typeof Symbol === "function") {
|
||||
Object.getOwnPropertyDescriptor(Symbol("foo"));
|
||||
}
|
||||
Object.getOwnPropertyDescriptor(Symbol("foo"));
|
||||
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor("foo", "length"), {
|
||||
value: 3,
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Coerce the argument passed to Object.getPrototypeOf using ToObject
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => Object.getPrototypeOf());
|
||||
@ -18,6 +19,4 @@ assert.throws(TypeError, () => Object.getPrototypeOf(null));
|
||||
assert.sameValue(Object.getPrototypeOf(1), Number.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(true), Boolean.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf("foo"), String.prototype);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.getPrototypeOf(Symbol("foo")), Symbol.prototype);
|
||||
}
|
||||
assert.sameValue(Object.getPrototypeOf(Symbol("foo")), Symbol.prototype);
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Object.isExtensible() should return false when given primitive values as input
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(), false);
|
||||
@ -17,6 +18,4 @@ assert.sameValue(Object.isExtensible(null), false);
|
||||
assert.sameValue(Object.isExtensible(1), false);
|
||||
assert.sameValue(Object.isExtensible("foo"), false);
|
||||
assert.sameValue(Object.isExtensible(true), false);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.isExtensible(Symbol()), false);
|
||||
}
|
||||
assert.sameValue(Object.isExtensible(Symbol()), false);
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Object.isFrozen() should return true when given primitive values as input
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isFrozen(), true);
|
||||
@ -17,6 +18,4 @@ assert.sameValue(Object.isFrozen(null), true);
|
||||
assert.sameValue(Object.isFrozen(1), true);
|
||||
assert.sameValue(Object.isFrozen("foo"), true);
|
||||
assert.sameValue(Object.isFrozen(true), true);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.isFrozen(Symbol()), true);
|
||||
}
|
||||
assert.sameValue(Object.isFrozen(Symbol()), true);
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Object.isSealed() should return true when given primitive values as input
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isSealed(), true);
|
||||
@ -17,6 +18,4 @@ assert.sameValue(Object.isSealed(null), true);
|
||||
assert.sameValue(Object.isSealed(1), true);
|
||||
assert.sameValue(Object.isSealed("foo"), true);
|
||||
assert.sameValue(Object.isSealed(true), true);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.isSealed(Symbol()), true);
|
||||
}
|
||||
assert.sameValue(Object.isSealed(Symbol()), true);
|
||||
|
@ -10,6 +10,7 @@ flags:
|
||||
description: |
|
||||
Coerce the argument passed to Object.keys using ToObject
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => Object.keys());
|
||||
@ -18,8 +19,6 @@ assert.throws(TypeError, () => Object.keys(null));
|
||||
|
||||
assert.compareArray(Object.keys(1), []);
|
||||
assert.compareArray(Object.keys(true), []);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.compareArray(Object.keys(Symbol("foo")), []);
|
||||
}
|
||||
assert.compareArray(Object.keys(Symbol("foo")), []);
|
||||
|
||||
assert.compareArray(Object.keys("foo"), ["0", "1", "2"]);
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Object.preventExtensions() should return its argument with no conversion when the argument is a primitive value
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.preventExtensions(), undefined);
|
||||
@ -17,6 +18,4 @@ assert.sameValue(Object.preventExtensions(null), null);
|
||||
assert.sameValue(Object.preventExtensions(1), 1);
|
||||
assert.sameValue(Object.preventExtensions("foo"), "foo");
|
||||
assert.sameValue(Object.preventExtensions(true), true);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.preventExtensions(Symbol.for("foo")), Symbol.for("foo"));
|
||||
}
|
||||
assert.sameValue(Object.preventExtensions(Symbol.for("foo")), Symbol.for("foo"));
|
||||
|
@ -8,6 +8,7 @@ flags:
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
@ -31,9 +32,7 @@ function logProxy(object) {
|
||||
return {proxy, log};
|
||||
}
|
||||
|
||||
var properties = ["string-property"];
|
||||
if (typeof Symbol === 'function')
|
||||
properties.push(Symbol("symbol-property"));
|
||||
var properties = ["string-property", Symbol("symbol-property")];
|
||||
|
||||
for (var property of properties) {
|
||||
// Test 1: property is not present on object
|
||||
|
@ -9,6 +9,7 @@ flags:
|
||||
description: |
|
||||
Object.seal() should return its argument with no conversion when the argument is a primitive value
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.seal(), undefined);
|
||||
@ -17,6 +18,4 @@ assert.sameValue(Object.seal(null), null);
|
||||
assert.sameValue(Object.seal(1), 1);
|
||||
assert.sameValue(Object.seal("foo"), "foo");
|
||||
assert.sameValue(Object.seal(true), true);
|
||||
if (typeof Symbol === "function") {
|
||||
assert.sameValue(Object.seal(Symbol.for("foo")), Symbol.for("foo"));
|
||||
}
|
||||
assert.sameValue(Object.seal(Symbol.for("foo")), Symbol.for("foo"));
|
||||
|
@ -10,6 +10,7 @@ flags:
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
features: [Symbol]
|
||||
---*/
|
||||
if ("values" in Object) {
|
||||
assert.sameValue(Object.values.length, 1);
|
||||
@ -65,8 +66,7 @@ if ("values" in Object) {
|
||||
|
||||
assert.compareArray(Object.values(1), []);
|
||||
assert.compareArray(Object.values(true), []);
|
||||
if (typeof Symbol === "function")
|
||||
assert.compareArray(Object.values(Symbol("foo")), []);
|
||||
assert.compareArray(Object.values(Symbol("foo")), []);
|
||||
|
||||
assert.compareArray(Object.values("foo"), ["f", "o", "o"]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user