Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Symbol/for/retrieve-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 es6id: 19.4.2.1
6 description: Retrieval of previously-created value
7 info: |
8 1. Let stringKey be ? ToString(key).
9 2. For each element e of the GlobalSymbolRegistry List,
10 a. If SameValue(e.[[Key]], stringKey) is true, return e.[[Symbol]].
11 3. Assert: GlobalSymbolRegistry does not currently contain an entry for
12 stringKey.
13 4. Let newSymbol be a new unique Symbol value whose [[Description]] value
14 is stringKey.
15 5. Append the Record { [[Key]]: stringKey, [[Symbol]]: newSymbol } to the
16 GlobalSymbolRegistry List.
17 6. Return newSymbol.
18 features: [Symbol]
19 ---*/
20
21 var canonical = Symbol.for('s');
22
23 assert.sameValue(typeof canonical, 'symbol');
24 assert.sameValue(canonical, Symbol.for('s'));