literal-property-name-bigint.js (1544B)
1 // Copyright (C) 2020 Igalia S.L, Toru Nagashima. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: > 6 BigInt in LiteralPropertyName must be valid and the property name must be 7 the string representation of the numeric value. 8 esid: prod-PropertyName 9 info: | 10 PropertyName[Yield, Await]: 11 LiteralPropertyName 12 ComputedPropertyName[?Yield, ?Await] 13 14 LiteralPropertyName: 15 IdentifierName 16 StringLiteral 17 NumericLiteral 18 19 NumericLiteral: 20 DecimalLiteral 21 DecimalBigIntegerLiteral 22 23 LiteralPropertyName: NumericLiteral 24 1. Let _nbr_ be the NumericValue of |NumericLiteral|. 25 1. Return ! ToString(_nbr_). 26 features: [BigInt, class, destructuring-binding, let] 27 ---*/ 28 29 // Property 30 31 let o = { 999999999999999999n: true }; // greater than max safe integer 32 33 assert.sameValue(o["999999999999999999"], true, 34 "the property name must be the string representation of the numeric value."); 35 36 // MethodDeclaration 37 38 o = { 1n() { return "bar"; } }; 39 assert.sameValue(o["1"](), "bar", 40 "the property name must be the string representation of the numeric value."); 41 42 class C { 43 1n() { return "baz"; } 44 } 45 46 let c = new C(); 47 assert.sameValue(c["1"](), "baz", 48 "the property name must be the string representation of the numeric value."); 49 50 // Destructuring 51 52 let { 1n: a } = { "1": "foo" }; 53 assert.sameValue(a, "foo", 54 "the property name must be the string representation of the numeric value."); 55 56 reportCompare(0, 0);