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-classes | 5 // Flags: --harmony-classes |
6 | 6 |
7 (function TestBasics() { | 7 (function TestBasics() { |
8 var C = class C {} | 8 var C = class C {} |
9 assertEquals(typeof C, 'function'); | 9 assertEquals(typeof C, 'function'); |
10 assertEquals(C.__proto__, Function.prototype); | 10 assertEquals(C.__proto__, Function.prototype); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 (function TestStrictMode() { | 152 (function TestStrictMode() { |
153 class C {} | 153 class C {} |
154 | 154 |
155 with ({a: 1}) { | 155 with ({a: 1}) { |
156 assertEquals(1, a); | 156 assertEquals(1, a); |
157 } | 157 } |
158 | 158 |
159 assertThrows('class C extends function B() { with ({}); return B; }() {}', | 159 assertThrows('class C extends function B() { with ({}); return B; }() {}', |
160 SyntaxError); | 160 SyntaxError); |
161 | 161 |
| 162 var D = class extends function() { |
| 163 arguments.caller; |
| 164 } {}; |
| 165 assertThrows(function() { |
| 166 Object.getPrototypeOf(D).arguments; |
| 167 }, TypeError); |
| 168 assertThrows(function() { |
| 169 new D; |
| 170 }, TypeError); |
162 })(); | 171 })(); |
163 | 172 |
164 | 173 |
165 (function TestToString() { | 174 (function TestToString() { |
166 class C {} | 175 class C {} |
167 assertEquals('class C {}', C.toString()); | 176 assertEquals('class C {}', C.toString()); |
168 | 177 |
169 class D { constructor() { 42; } } | 178 class D { constructor() { 42; } } |
170 assertEquals('class D { constructor() { 42; } }', D.toString()); | 179 assertEquals('class D { constructor() { 42; } }', D.toString()); |
171 | 180 |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 }, ReferenceError); | 770 }, ReferenceError); |
762 | 771 |
763 assertThrows(function() { | 772 assertThrows(function() { |
764 (class x extends x {}); | 773 (class x extends x {}); |
765 }, ReferenceError); | 774 }, ReferenceError); |
766 | 775 |
767 assertThrows(function() { | 776 assertThrows(function() { |
768 var x = (class x extends x {}); | 777 var x = (class x extends x {}); |
769 }, ReferenceError); | 778 }, ReferenceError); |
770 })(); | 779 })(); |
OLD | NEW |