number-duplicates.js (1189B)
1 // Copyright (C) 2014 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 12.2.5 5 description: > 6 computed property names can be numbers 7 ---*/ 8 var object = { 9 [1.2]: 'A', 10 [1e55]: 'B', 11 [0.000001]: 'C', 12 [-0]: 'D', 13 [Infinity]: 'E', 14 [-Infinity]: 'F', 15 [NaN]: 'G', 16 }; 17 assert.sameValue( 18 object['1.2'], 19 'A', 20 "The value of `object['1.2']` is `'A'`. Defined as `[1.2]: 'A'`" 21 ); 22 assert.sameValue( 23 object['1e+55'], 24 'B', 25 "The value of `object['1e+55']` is `'B'`. Defined as `[1e55]: 'B'`" 26 ); 27 assert.sameValue( 28 object['0.000001'], 29 'C', 30 "The value of `object['0.000001']` is `'C'`. Defined as `[0.000001]: 'C'`" 31 ); 32 assert.sameValue( 33 object[0], 34 'D', 35 "The value of `object[0]` is `'D'`. Defined as `[-0]: 'D'`" 36 ); 37 assert.sameValue(object[Infinity], 38 'E', 39 "The value of `object[Infinity]` is `'E'`. Defined as `[Infinity]: 'E'`" 40 ); 41 assert.sameValue( 42 object[-Infinity], 43 'F', 44 "The value of `object[-Infinity]` is `'F'`. Defined as `[-Infinity]: 'F'`" 45 ); 46 assert.sameValue( 47 object[NaN], 48 'G', 49 "The value of `object[NaN]` is `'G'`. Defined as `[NaN]: 'G'`" 50 ); 51 52 reportCompare(0, 0);