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-sloppy --allow-natives-syntax | 5 // Flags: --harmony-sloppy --harmony-function-name --allow-natives-syntax |
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); |
11 assertEquals(Object.prototype, Object.getPrototypeOf(C.prototype)); | 11 assertEquals(Object.prototype, Object.getPrototypeOf(C.prototype)); |
12 assertEquals(Function.prototype, Object.getPrototypeOf(C)); | 12 assertEquals(Function.prototype, Object.getPrototypeOf(C)); |
13 assertEquals('C', C.name); | 13 assertEquals('C', C.name); |
14 | 14 |
15 class D {} | 15 class D {} |
16 assertEquals(typeof D, 'function'); | 16 assertEquals(typeof D, 'function'); |
17 assertEquals(D.__proto__, Function.prototype); | 17 assertEquals(D.__proto__, Function.prototype); |
18 assertEquals(Object.prototype, Object.getPrototypeOf(D.prototype)); | 18 assertEquals(Object.prototype, Object.getPrototypeOf(D.prototype)); |
19 assertEquals(Function.prototype, Object.getPrototypeOf(D)); | 19 assertEquals(Function.prototype, Object.getPrototypeOf(D)); |
20 assertEquals('D', D.name); | 20 assertEquals('D', D.name); |
21 | 21 |
22 class D2 { constructor() {} } | 22 class D2 { constructor() {} } |
23 assertEquals('D2', D2.name); | 23 assertEquals('D2', D2.name); |
24 | 24 |
25 // TODO(arv): The logic for the name of anonymous functions in ES6 requires | |
26 // the below to be 'E'; | |
27 var E = class {} | 25 var E = class {} |
28 assertEquals('', E.name); // Should be 'E'. | 26 assertEquals('E', E.name); // Should be 'E'. |
29 | 27 |
30 var F = class { constructor() {} }; | 28 var F = class { constructor() {} }; |
31 assertEquals('', F.name); // Should be 'F'. | 29 assertEquals('F', F.name); // Should be 'F'. |
32 })(); | 30 })(); |
33 | 31 |
34 | 32 |
35 (function TestBasicsExtends() { | 33 (function TestBasicsExtends() { |
36 class C extends null {} | 34 class C extends null {} |
37 assertEquals(typeof C, 'function'); | 35 assertEquals(typeof C, 'function'); |
38 assertEquals(C.__proto__, Function.prototype); | 36 assertEquals(C.__proto__, Function.prototype); |
39 assertEquals(null, Object.getPrototypeOf(C.prototype)); | 37 assertEquals(null, Object.getPrototypeOf(C.prototype)); |
40 | 38 |
41 class D extends C {} | 39 class D extends C {} |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 testClassRestrictedProperties(ClassWithDefaultConstructor); | 987 testClassRestrictedProperties(ClassWithDefaultConstructor); |
990 testClassRestrictedProperties(Class); | 988 testClassRestrictedProperties(Class); |
991 testClassRestrictedProperties(DerivedClassWithDefaultConstructor); | 989 testClassRestrictedProperties(DerivedClassWithDefaultConstructor); |
992 testClassRestrictedProperties(DerivedClass); | 990 testClassRestrictedProperties(DerivedClass); |
993 testClassRestrictedProperties(class { method() {} }); | 991 testClassRestrictedProperties(class { method() {} }); |
994 testClassRestrictedProperties(class { constructor() {} method() {} }); | 992 testClassRestrictedProperties(class { constructor() {} method() {} }); |
995 testClassRestrictedProperties(class extends Class { }); | 993 testClassRestrictedProperties(class extends Class { }); |
996 testClassRestrictedProperties( | 994 testClassRestrictedProperties( |
997 class extends Class { constructor() { super(); } }); | 995 class extends Class { constructor() { super(); } }); |
998 })(); | 996 })(); |
OLD | NEW |