Debian Codegraph @

js/src/tests/test262/built-ins/Symbol/for/create-value.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-symbol.for
5 description: Creation of a unique Symbol value
6 info: |
7 1. Let stringKey be ? ToString(key).
8 2. For each element e of the GlobalSymbolRegistry List,
9 a. If SameValue(e.[[Key]], stringKey) is true, return e.[[Symbol]].
10 3. Assert: GlobalSymbolRegistry does not currently contain an entry for
11 stringKey.
12 4. Let newSymbol be a new unique Symbol value whose [[Description]] value
13 is stringKey.
14 5. Append the Record { [[Key]]: stringKey, [[Symbol]]: newSymbol } to the
15 GlobalSymbolRegistry List.
16 6. Return newSymbol.
17 features: [Symbol]
18 ---*/
19
20 var canonical = Symbol.for('s');
21
22 assert.sameValue(typeof canonical, 'symbol');
23 assert.notSameValue(canonical, Symbol('s'));
24 assert.notSameValue(canonical, Symbol.for('y'));
25
26 reportCompare(0, 0);