string.js (1035B)
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 class method names can be a string 7 includes: [compareArray.js] 8 ---*/ 9 10 function ID(x) { 11 return x; 12 } 13 14 class C { 15 a() { return 'A'} 16 ['b']() { return 'B'; } 17 c() { return 'C'; } 18 [ID('d')]() { return 'D'; } 19 } 20 assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`. Defined as `a() { return 'A'}`"); 21 assert.sameValue(new C().b(), 'B', "`new C().b()` returns `'B'`. Defined as `['b']() { return 'B'; }`"); 22 assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`. Defined as `c() { return 'C'; }`"); 23 assert.sameValue(new C().d(), 'D', "`new C().d()` returns `'D'`. Defined as `[ID('d')]() { return 'D'; }`"); 24 assert.sameValue(Object.keys(C.prototype).length, 0, "No enum keys from C.prototype"); 25 assert.compareArray( 26 Object.getOwnPropertyNames(C.prototype), 27 ['constructor', 'a', 'b', 'c', 'd'] 28 ); 29 30 reportCompare(0, 0);