Debian Codegraph @

js/src/tests/test262/language/expressions/optional-chaining/optional-chain-prod-identifiername.js

raw
1 // Copyright 2020 Salesforce.com, Inc. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: prod-OptionalExpression
6 description: >
7 Productions for ?. IdentifierName
8 info: |
9 OptionalChain[Yield, Await]:
10 ?. IdentifierName
11 features: [optional-chaining]
12 ---*/
13
14 const arr = [10, 11];
15 const obj = {
16 a: 'hello'
17 };
18
19 assert.sameValue(obj?.a, 'hello');
20 assert.sameValue(obj?.\u0061, 'hello');
21 assert.sameValue(obj?.\u{0061}, 'hello');
22
23 assert.sameValue(obj?.\u0062, undefined);
24 assert.sameValue(obj?.\u{0062}, undefined);
25
26 assert.sameValue(arr ?. length, 2);
27 assert.sameValue(arr ?. l\u0065ngth, 2);
28 assert.sameValue(arr ?. l\u{0065}ngth, 2);
29
30 assert.sameValue(obj?.$, undefined);
31
32 obj.$ = 42;
33 assert.sameValue(obj?.$, 42);
34
35 assert.sameValue(obj?._, undefined);
36
37 obj._ = 39;
38 assert.sameValue(obj?._, 39);
39
40 reportCompare(0, 0);