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: --allow-unsafe-function-constructor | 5 // Flags: --allow-unsafe-function-constructor |
6 | 6 |
7 | 7 |
8 (function testReflectConstructArity() { | 8 (function testReflectConstructArity() { |
9 assertEquals(2, Reflect.construct.length); | 9 assertEquals(2, Reflect.construct.length); |
10 })(); | 10 })(); |
11 | 11 |
12 | 12 |
13 (function testReflectConstructNonConstructor() { | 13 (function testReflectConstructNonConstructor() { |
14 assertThrows(function() { | 14 assertThrows(function() { |
15 new Reflect.construct(function(){}, []); | 15 new Reflect.construct(function(){}, []); |
16 }, TypeError); | 16 }, TypeError); |
17 })(); | 17 })(); |
18 | 18 |
19 | 19 |
| 20 (function testReflectConstructArg1NonConstructor() { |
| 21 try { |
| 22 Reflect.construct(() => {}, []); |
| 23 } catch (e) { |
| 24 assertInstanceof(e, TypeError); |
| 25 assertEquals("() => {} is not a constructor", e.message); |
| 26 return; |
| 27 } |
| 28 assertUnreachable("Exception expected"); |
| 29 })(); |
| 30 |
| 31 |
| 32 (function testReflectConstructArg3NonConstructor() { |
| 33 try { |
| 34 Reflect.construct(function() {}, [], () => {}); |
| 35 } catch (e) { |
| 36 assertInstanceof(e, TypeError); |
| 37 assertEquals("() => {} is not a constructor", e.message); |
| 38 return; |
| 39 } |
| 40 assertUnreachable("Exception expected"); |
| 41 })(); |
| 42 |
| 43 |
20 (function testReflectConstructBasic() { | 44 (function testReflectConstructBasic() { |
21 function Constructor() { "use strict"; } | 45 function Constructor() { "use strict"; } |
22 assertInstanceof(Reflect.construct(Constructor, []), Constructor); | 46 assertInstanceof(Reflect.construct(Constructor, []), Constructor); |
23 })(); | 47 })(); |
24 | 48 |
25 | 49 |
26 (function testReflectConstructBasicSloppy() { | 50 (function testReflectConstructBasicSloppy() { |
27 function Constructor() {} | 51 function Constructor() {} |
28 assertInstanceof(Reflect.construct(Constructor, []), Constructor); | 52 assertInstanceof(Reflect.construct(Constructor, []), Constructor); |
29 })(); | 53 })(); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 for (var realm of [realm1, realm2]) { | 393 for (var realm of [realm1, realm2]) { |
370 test(realm, getname(intrinsic), getargs(intrinsic), convert); | 394 test(realm, getname(intrinsic), getargs(intrinsic), convert); |
371 } | 395 } |
372 } | 396 } |
373 } | 397 } |
374 | 398 |
375 test_all(test_intrinsic_default, (v)=>v); | 399 test_all(test_intrinsic_default, (v)=>v); |
376 test_all(test_intrinsic_default, | 400 test_all(test_intrinsic_default, |
377 (v)=>{ "use strict"; return class extends v {}}); | 401 (v)=>{ "use strict"; return class extends v {}}); |
378 })(); | 402 })(); |
OLD | NEW |