Replace runtime checks for Symbol with feature tag

This commit is contained in:
André Bargull 2025-04-30 14:16:14 +02:00 committed by Philip Chimento
parent c35a9c74ba
commit 193801b9d4
14 changed files with 29 additions and 41 deletions

View File

@ -10,6 +10,7 @@ flags:
description: | description: |
Implement %TypedArray%.prototype.{find, findIndex} Implement %TypedArray%.prototype.{find, findIndex}
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
const methods = ["find", "findIndex"]; 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 === 3), 3);
assert.sameValue(arr[method](v => v === 6), method === "find" ? undefined : -1); assert.sameValue(arr[method](v => v === 6), method === "find" ? undefined : -1);
var thisValues = [undefined, null, true, 1, "foo", [], {}]; var thisValues = [undefined, null, true, 1, "foo", [], {}, Symbol()];
if (typeof Symbol == "function")
thisValues.push(Symbol());
thisValues.forEach(thisArg => thisValues.forEach(thisArg =>
assert.throws(TypeError, () => arr[method].call(thisArg, () => true)) assert.throws(TypeError, () => arr[method].call(thisArg, () => true))

View File

@ -10,6 +10,7 @@ flags:
description: | description: |
Implement %TypedArray%.prototype.{findLast, findLastIndex} Implement %TypedArray%.prototype.{findLast, findLastIndex}
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
const methods = ["findLast", "findLastIndex"]; 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 === 3), 3);
assert.sameValue(arr[method](v => v === 6), method === "findLast" ? undefined : -1); assert.sameValue(arr[method](v => v === 6), method === "findLast" ? undefined : -1);
var thisValues = [undefined, null, true, 1, "foo", [], {}]; var thisValues = [undefined, null, true, 1, "foo", [], {}, Symbol()];
if (typeof Symbol == "function")
thisValues.push(Symbol());
thisValues.forEach(thisArg => thisValues.forEach(thisArg =>
assert.throws(TypeError, () => arr[method].call(thisArg, () => true)) assert.throws(TypeError, () => arr[method].call(thisArg, () => true))

View File

@ -10,7 +10,9 @@ flags:
description: | description: |
pending pending
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
if ("entries" in Object) { if ("entries" in Object) {
assert.sameValue(Object.entries.length, 1); assert.sameValue(Object.entries.length, 1);
@ -65,8 +67,7 @@ if ("entries" in Object) {
assert.deepEqual(Object.entries(1), []); assert.deepEqual(Object.entries(1), []);
assert.deepEqual(Object.entries(true), []); 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"]]); assert.deepEqual(Object.entries("foo"), [["0", "f"], ["1", "o"], ["2", "o"]]);

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Object.freeze() should return its argument with no conversion when the argument is a primitive value Object.freeze() should return its argument with no conversion when the argument is a primitive value
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.sameValue(Object.freeze(), undefined); 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(1), 1);
assert.sameValue(Object.freeze("foo"), "foo"); assert.sameValue(Object.freeze("foo"), "foo");
assert.sameValue(Object.freeze(true), true); 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"));
}

View File

@ -10,6 +10,7 @@ flags:
description: | description: |
Coerce the argument passed to Object.getOwnPropertyDescriptor using ToObject Coerce the argument passed to Object.getOwnPropertyDescriptor using ToObject
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.throws(TypeError, () => Object.getOwnPropertyDescriptor()); assert.throws(TypeError, () => Object.getOwnPropertyDescriptor());
@ -18,9 +19,7 @@ assert.throws(TypeError, () => Object.getOwnPropertyDescriptor(null));
Object.getOwnPropertyDescriptor(1); Object.getOwnPropertyDescriptor(1);
Object.getOwnPropertyDescriptor(true); Object.getOwnPropertyDescriptor(true);
if (typeof Symbol === "function") { Object.getOwnPropertyDescriptor(Symbol("foo"));
Object.getOwnPropertyDescriptor(Symbol("foo"));
}
assert.deepEqual(Object.getOwnPropertyDescriptor("foo", "length"), { assert.deepEqual(Object.getOwnPropertyDescriptor("foo", "length"), {
value: 3, value: 3,

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Coerce the argument passed to Object.getPrototypeOf using ToObject Coerce the argument passed to Object.getPrototypeOf using ToObject
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.throws(TypeError, () => Object.getPrototypeOf()); 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(1), Number.prototype);
assert.sameValue(Object.getPrototypeOf(true), Boolean.prototype); assert.sameValue(Object.getPrototypeOf(true), Boolean.prototype);
assert.sameValue(Object.getPrototypeOf("foo"), String.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);
}

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Object.isExtensible() should return false when given primitive values as input Object.isExtensible() should return false when given primitive values as input
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.sameValue(Object.isExtensible(), false); 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(1), false);
assert.sameValue(Object.isExtensible("foo"), false); assert.sameValue(Object.isExtensible("foo"), false);
assert.sameValue(Object.isExtensible(true), false); assert.sameValue(Object.isExtensible(true), false);
if (typeof Symbol === "function") { assert.sameValue(Object.isExtensible(Symbol()), false);
assert.sameValue(Object.isExtensible(Symbol()), false);
}

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Object.isFrozen() should return true when given primitive values as input Object.isFrozen() should return true when given primitive values as input
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.sameValue(Object.isFrozen(), true); 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(1), true);
assert.sameValue(Object.isFrozen("foo"), true); assert.sameValue(Object.isFrozen("foo"), true);
assert.sameValue(Object.isFrozen(true), true); assert.sameValue(Object.isFrozen(true), true);
if (typeof Symbol === "function") { assert.sameValue(Object.isFrozen(Symbol()), true);
assert.sameValue(Object.isFrozen(Symbol()), true);
}

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Object.isSealed() should return true when given primitive values as input Object.isSealed() should return true when given primitive values as input
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.sameValue(Object.isSealed(), true); 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(1), true);
assert.sameValue(Object.isSealed("foo"), true); assert.sameValue(Object.isSealed("foo"), true);
assert.sameValue(Object.isSealed(true), true); assert.sameValue(Object.isSealed(true), true);
if (typeof Symbol === "function") { assert.sameValue(Object.isSealed(Symbol()), true);
assert.sameValue(Object.isSealed(Symbol()), true);
}

View File

@ -10,6 +10,7 @@ flags:
description: | description: |
Coerce the argument passed to Object.keys using ToObject Coerce the argument passed to Object.keys using ToObject
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.throws(TypeError, () => Object.keys()); assert.throws(TypeError, () => Object.keys());
@ -18,8 +19,6 @@ assert.throws(TypeError, () => Object.keys(null));
assert.compareArray(Object.keys(1), []); assert.compareArray(Object.keys(1), []);
assert.compareArray(Object.keys(true), []); 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"]); assert.compareArray(Object.keys("foo"), ["0", "1", "2"]);

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Object.preventExtensions() should return its argument with no conversion when the argument is a primitive value Object.preventExtensions() should return its argument with no conversion when the argument is a primitive value
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.sameValue(Object.preventExtensions(), undefined); 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(1), 1);
assert.sameValue(Object.preventExtensions("foo"), "foo"); assert.sameValue(Object.preventExtensions("foo"), "foo");
assert.sameValue(Object.preventExtensions(true), true); 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"));
}

View File

@ -8,6 +8,7 @@ flags:
description: | description: |
pending pending
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
@ -31,9 +32,7 @@ function logProxy(object) {
return {proxy, log}; return {proxy, log};
} }
var properties = ["string-property"]; var properties = ["string-property", Symbol("symbol-property")];
if (typeof Symbol === 'function')
properties.push(Symbol("symbol-property"));
for (var property of properties) { for (var property of properties) {
// Test 1: property is not present on object // Test 1: property is not present on object

View File

@ -9,6 +9,7 @@ flags:
description: | description: |
Object.seal() should return its argument with no conversion when the argument is a primitive value Object.seal() should return its argument with no conversion when the argument is a primitive value
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
assert.sameValue(Object.seal(), undefined); 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(1), 1);
assert.sameValue(Object.seal("foo"), "foo"); assert.sameValue(Object.seal("foo"), "foo");
assert.sameValue(Object.seal(true), true); 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"));
}

View File

@ -10,6 +10,7 @@ flags:
description: | description: |
pending pending
esid: pending esid: pending
features: [Symbol]
---*/ ---*/
if ("values" in Object) { if ("values" in Object) {
assert.sameValue(Object.values.length, 1); assert.sameValue(Object.values.length, 1);
@ -65,8 +66,7 @@ if ("values" in Object) {
assert.compareArray(Object.values(1), []); assert.compareArray(Object.values(1), []);
assert.compareArray(Object.values(true), []); 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"]); assert.compareArray(Object.values("foo"), ["f", "o", "o"]);