From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../built-ins/Symbol/keyFor/arg-non-symbol.js | 47 ++++++++++++++++++++++ .../Symbol/keyFor/arg-symbol-registry-hit.js | 17 ++++++++ .../Symbol/keyFor/arg-symbol-registry-miss.js | 24 +++++++++++ .../test262/built-ins/Symbol/keyFor/browser.js | 0 .../test262/built-ins/Symbol/keyFor/cross-realm.js | 21 ++++++++++ .../test262/built-ins/Symbol/keyFor/length.js | 32 +++++++++++++++ .../tests/test262/built-ins/Symbol/keyFor/name.js | 29 +++++++++++++ .../built-ins/Symbol/keyFor/not-a-constructor.js | 31 ++++++++++++++ .../test262/built-ins/Symbol/keyFor/prop-desc.js | 20 +++++++++ .../tests/test262/built-ins/Symbol/keyFor/shell.js | 0 10 files changed, 221 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/arg-non-symbol.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-hit.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-miss.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/browser.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/cross-realm.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/length.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/name.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Symbol/keyFor/shell.js (limited to 'js/src/tests/test262/built-ins/Symbol/keyFor') diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/arg-non-symbol.js b/js/src/tests/test262/built-ins/Symbol/keyFor/arg-non-symbol.js new file mode 100644 index 0000000000..3b5b793299 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/arg-non-symbol.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-symbol.keyfor +description: Called with a non-symbol argument +info: | + 1. If Type(sym) is not Symbol, throw a TypeError exception. +features: [Symbol] +---*/ + +assert.sameValue(typeof Symbol.keyFor, 'function'); + +assert.throws(TypeError, function() { + Symbol.keyFor(null); +}, 'null'); + +assert.throws(TypeError, function() { + Symbol.keyFor(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + Symbol.keyFor('1'); +}, 'number'); + +assert.throws(TypeError, function() { + Symbol.keyFor(''); +}, 'string'); + +assert.throws(TypeError, function() { + Symbol.keyFor({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + Symbol.keyFor([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + Symbol.keyFor(arguments); +}, 'arguments exotic object'); + +var subject = Object(Symbol('s')); + +assert.throws(TypeError, function() { + Symbol.keyFor(subject); +}, 'symbol object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-hit.js b/js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-hit.js new file mode 100644 index 0000000000..f3019ec719 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-hit.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-symbol.keyfor +description: Called with Symbol value that exists in the global symbol registry +info: | + 1. If Type(sym) is not Symbol, throw a TypeError exception. + 2. For each element e of the GlobalSymbolRegistry List (see 19.4.2.1), + a. If SameValue(e.[[Symbol]], sym) is true, return e.[[Key]]. +features: [Symbol] +---*/ + +var canonical = Symbol.for('s'); + +assert.sameValue(Symbol.keyFor(canonical), 's'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-miss.js b/js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-miss.js new file mode 100644 index 0000000000..48bb621536 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/arg-symbol-registry-miss.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-symbol.keyfor +description: > + Called with Symbol value that does not exist in the global symbol registry +info: | + 1. If Type(sym) is not Symbol, throw a TypeError exception. + 2. For each element e of the GlobalSymbolRegistry List (see 19.4.2.1), + a. If SameValue(e.[[Symbol]], sym) is true, return e.[[Key]]. + 3. Assert: GlobalSymbolRegistry does not currently contain an entry for + sym. + 4. Return undefined. +features: [Symbol.iterator, Symbol] +---*/ + +var constructed = Symbol('Symbol.iterator'); +assert.sameValue(Symbol.keyFor(constructed), undefined, 'constructed symbol'); + +assert.sameValue( + Symbol.keyFor(Symbol.iterator), undefined, 'well-known symbol' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/browser.js b/js/src/tests/test262/built-ins/Symbol/keyFor/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/cross-realm.js b/js/src/tests/test262/built-ins/Symbol/keyFor/cross-realm.js new file mode 100644 index 0000000000..a052c994c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/cross-realm.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-symbol.keyfor +description: Global symbol registry is shared by all realms +info: | + The GlobalSymbolRegistry is a List that is globally available. It is shared + by all realms. Prior to the evaluation of any ECMAScript code it is + initialized as a new empty List. +features: [cross-realm, Symbol] +---*/ + +var OSymbol = $262.createRealm().global.Symbol; +var parent = Symbol.for('parent'); +var child = OSymbol.for('child'); + +assert.notSameValue(Symbol.keyFor, OSymbol.keyFor); +assert.sameValue(OSymbol.keyFor(parent), 'parent'); +assert.sameValue(Symbol.keyFor(child), 'child'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/length.js b/js/src/tests/test262/built-ins/Symbol/keyFor/length.js new file mode 100644 index 0000000000..8f1296daf6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.4.2.5 +description: > + Symbol.keyFor.length is 1. +info: | + Symbol.keyFor ( sym ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +assert.sameValue(Symbol.keyFor.length, 1); + +verifyNotEnumerable(Symbol.keyFor, "length"); +verifyNotWritable(Symbol.keyFor, "length"); +verifyConfigurable(Symbol.keyFor, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/name.js b/js/src/tests/test262/built-ins/Symbol/keyFor/name.js new file mode 100644 index 0000000000..10adeeb674 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.4.2.5 +description: > + Symbol.keyFor.name is "keyFor". +info: | + Symbol.keyFor ( sym ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +assert.sameValue(Symbol.keyFor.name, "keyFor"); + +verifyNotEnumerable(Symbol.keyFor, "name"); +verifyNotWritable(Symbol.keyFor, "name"); +verifyConfigurable(Symbol.keyFor, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js b/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js new file mode 100644 index 0000000000..61d6b676d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Symbol.keyFor does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Symbol, arrow-function] +---*/ + +assert.sameValue(isConstructor(Symbol.keyFor), false, 'isConstructor(Symbol.keyFor) must return false'); + +assert.throws(TypeError, () => { + new Symbol.keyFor(Symbol()); +}, '`new Symbol.keyFor(Symbol())` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/prop-desc.js b/js/src/tests/test262/built-ins/Symbol/keyFor/prop-desc.js new file mode 100644 index 0000000000..97603d9e79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/prop-desc.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-symbol.keyfor +description: Property descriptor +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +assert.sameValue(typeof Symbol.keyFor, 'function'); + +verifyNotEnumerable(Symbol, 'keyFor'); +verifyWritable(Symbol, 'keyFor'); +verifyConfigurable(Symbol, 'keyFor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/shell.js b/js/src/tests/test262/built-ins/Symbol/keyFor/shell.js new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3