string.js (880B)
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 a string 7 includes: [compareArray.js] 8 ---*/ 9 function ID(x) { 10 return x; 11 } 12 13 var object = { 14 a: 'A', 15 ['b']: 'B', 16 c: 'C', 17 [ID('d')]: 'D', 18 }; 19 assert.sameValue(object.a, 'A', "The value of `object.a` is `'A'`. Defined in `object` as `a: 'A'`"); 20 assert.sameValue(object.b, 'B', "The value of `object.b` is `'B'`. Defined in `object` as `['b']: 'B'`"); 21 assert.sameValue(object.c, 'C', "The value of `object.c` is `'C'`. Defined in `object` as `c: 'C'`"); 22 assert.sameValue(object.d, 'D', "The value of `object.d` is `'D'`. Defined in `object` as `[ID('d')]: 'D'`"); 23 assert.compareArray( 24 Object.getOwnPropertyNames(object), 25 ['a', 'b', 'c', 'd'] 26 ); 27 28 reportCompare(0, 0);