OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-computed-property-names | 5 // Flags: --harmony-computed-property-names |
6 | 6 |
7 | 7 |
8 function ID(x) { | 8 function ID(x) { |
9 return x; | 9 return x; |
10 } | 10 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 assertEquals(proto, object.__proto__); | 270 assertEquals(proto, object.__proto__); |
271 assertTrue(object.hasOwnProperty('__proto__')); | 271 assertTrue(object.hasOwnProperty('__proto__')); |
272 | 272 |
273 object = { | 273 object = { |
274 [ID('x')]: 'X', | 274 [ID('x')]: 'X', |
275 __proto__: proto | 275 __proto__: proto |
276 }; | 276 }; |
277 assertEquals('X', object.x); | 277 assertEquals('X', object.x); |
278 assertEquals(proto, Object.getPrototypeOf(object)); | 278 assertEquals(proto, Object.getPrototypeOf(object)); |
279 })(); | 279 })(); |
| 280 |
| 281 |
| 282 (function TestExceptionInName() { |
| 283 function MyError() {}; |
| 284 function throwMyError() { |
| 285 throw new MyError(); |
| 286 } |
| 287 assertThrows(function() { |
| 288 var o = { |
| 289 [throwMyError()]: 42 |
| 290 }; |
| 291 }, MyError); |
| 292 assertThrows(function() { |
| 293 var o = { |
| 294 get [throwMyError()]() { return 42; } |
| 295 }; |
| 296 }, MyError); |
| 297 assertThrows(function() { |
| 298 var o = { |
| 299 set [throwMyError()](_) { } |
| 300 }; |
| 301 }, MyError); |
| 302 })(); |
OLD | NEW |