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-natives-syntax | 5 // Flags: --allow-natives-syntax --harmony-do-expressions |
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 {} |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 testClassRestrictedProperties(ClassWithDefaultConstructor); | 987 testClassRestrictedProperties(ClassWithDefaultConstructor); |
988 testClassRestrictedProperties(Class); | 988 testClassRestrictedProperties(Class); |
989 testClassRestrictedProperties(DerivedClassWithDefaultConstructor); | 989 testClassRestrictedProperties(DerivedClassWithDefaultConstructor); |
990 testClassRestrictedProperties(DerivedClass); | 990 testClassRestrictedProperties(DerivedClass); |
991 testClassRestrictedProperties(class { method() {} }); | 991 testClassRestrictedProperties(class { method() {} }); |
992 testClassRestrictedProperties(class { constructor() {} method() {} }); | 992 testClassRestrictedProperties(class { constructor() {} method() {} }); |
993 testClassRestrictedProperties(class extends Class { }); | 993 testClassRestrictedProperties(class extends Class { }); |
994 testClassRestrictedProperties( | 994 testClassRestrictedProperties( |
995 class extends Class { constructor() { super(); } }); | 995 class extends Class { constructor() { super(); } }); |
996 })(); | 996 })(); |
| 997 |
| 998 |
| 999 (function testReturnFromClassLiteral() { |
| 1000 |
| 1001 function usingDoExpressionInBody() { |
| 1002 let x = 42; |
| 1003 let dummy = function() {x}; |
| 1004 try { |
| 1005 class C { |
| 1006 dummy() {C} |
| 1007 [do {return}]() {} |
| 1008 }; |
| 1009 } finally { |
| 1010 return x; |
| 1011 } |
| 1012 } |
| 1013 assertEquals(42, usingDoExpressionInBody()); |
| 1014 |
| 1015 function usingDoExpressionInExtends() { |
| 1016 let x = 42; |
| 1017 let dummy = function() {x}; |
| 1018 try { |
| 1019 class C extends (do {return}) { dummy() {C} }; |
| 1020 } finally { |
| 1021 return x; |
| 1022 } |
| 1023 } |
| 1024 assertEquals(42, usingDoExpressionInExtends()); |
| 1025 |
| 1026 function usingYieldInBody() { |
| 1027 function* foo() { |
| 1028 class C { |
| 1029 [yield]() {} |
| 1030 } |
| 1031 } |
| 1032 var g = foo(); |
| 1033 g.next(); |
| 1034 return g.return(42).value; |
| 1035 } |
| 1036 assertEquals(42, usingYieldInBody()); |
| 1037 |
| 1038 function usingYieldInExtends() { |
| 1039 function* foo() { |
| 1040 class C extends (yield) {}; |
| 1041 } |
| 1042 var g = foo(); |
| 1043 g.next(); |
| 1044 return g.return(42).value; |
| 1045 } |
| 1046 assertEquals(42, usingYieldInExtends()); |
| 1047 |
| 1048 })(); |
OLD | NEW |