OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | 23 |
24 // Flags: --harmony-sloppy | 24 // Flags: --harmony-sloppy |
25 | 25 |
26 description('Tests for calling the constructors of ES6 classes'); | 26 description('Tests for calling the constructors of ES6 classes'); |
27 | 27 |
28 class A { constructor() {} }; | 28 class A { constructor() {} }; |
29 class B extends A { constructor() { super() } }; | 29 class B extends A { constructor() { super() } }; |
30 | 30 |
31 shouldNotThrow('new A'); | 31 shouldNotThrow('new A'); |
32 shouldThrow('A()', '"TypeError: Class constructors cannot be invoked without \'n
ew\'"'); | 32 shouldThrow('A()', '"TypeError: Class constructor A cannot be invoked without \'
new\'"'); |
33 shouldNotThrow('new B'); | 33 shouldNotThrow('new B'); |
34 shouldThrow('B()', '"TypeError: Class constructors cannot be invoked without \'n
ew\'"'); | 34 shouldThrow('B()', '"TypeError: Class constructor B cannot be invoked without \'
new\'"'); |
35 shouldNotThrow('new (class { constructor() {} })()'); | 35 shouldNotThrow('new (class { constructor() {} })()'); |
36 shouldThrow('(class { constructor() {} })()', '"TypeError: Class constructors ca
nnot be invoked without \'new\'"'); | 36 shouldThrow('(class { constructor() {} })()', '"TypeError: Class constructor ca
nnot be invoked without \'new\'"'); |
37 shouldThrow('new (class extends null { constructor() { super() } })()', '"TypeEr
ror: function () {} is not a constructor"'); | 37 shouldThrow('new (class extends null { constructor() { super() } })()', '"TypeEr
ror: super is not a constructor"'); |
38 shouldThrow('(class extends null { constructor() { super() } })()', '"TypeError:
Class constructors cannot be invoked without \'new\'"'); | 38 shouldThrow('(class extends null { constructor() { super() } })()', '"TypeError:
Class constructor cannot be invoked without \'new\'"'); |
39 | 39 |
40 var successfullyParsed = true; | 40 var successfullyParsed = true; |
OLD | NEW |