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 --harmony-do-expressions | 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); |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 function* foo() { | 1039 function* foo() { |
1040 class C extends (yield) {}; | 1040 class C extends (yield) {}; |
1041 } | 1041 } |
1042 var g = foo(); | 1042 var g = foo(); |
1043 g.next(); | 1043 g.next(); |
1044 return g.return(42).value; | 1044 return g.return(42).value; |
1045 } | 1045 } |
1046 assertEquals(42, usingYieldInExtends()); | 1046 assertEquals(42, usingYieldInExtends()); |
1047 | 1047 |
1048 })(); | 1048 })(); |
| 1049 |
| 1050 (function TestEvaluationOrder() { |
| 1051 var effects = []; |
| 1052 |
| 1053 (class extends (effects.push(0), function(){ assertUnreachable(); }) { |
| 1054 [(effects.push(1), { toString(){ effects.push(2); } })](){} |
| 1055 static [(effects.push(3), { toString(){ effects.push(4); } })](){} |
| 1056 [(effects.push(5), { toString(){ effects.push(6); } })](){} |
| 1057 static [(effects.push(7), { toString(){ effects.push(8); } })](){} |
| 1058 }); |
| 1059 assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8], effects); |
| 1060 })(); |
| 1061 |
| 1062 (function TestComputedPropertyNamedConstructor() { |
| 1063 const constructor_sigil = {}; |
| 1064 const nonconstructor_sigil = {}; |
| 1065 |
| 1066 class DefaultConstructor { |
| 1067 ["constructor"](){ return nonconstructor_sigil; } |
| 1068 } |
| 1069 assertInstanceof(new DefaultConstructor, DefaultConstructor); |
| 1070 assertEquals((new DefaultConstructor).constructor(), nonconstructor_sigil); |
| 1071 |
| 1072 class PreceedingConstructor { |
| 1073 constructor(){ return constructor_sigil; } |
| 1074 ["constructor"](){ return nonconstructor_sigil; } |
| 1075 } |
| 1076 assertEquals(new PreceedingConstructor, constructor_sigil); |
| 1077 assertEquals((new PreceedingConstructor).constructor(), nonconstructor_sigil); |
| 1078 |
| 1079 class FollowingConstructor { |
| 1080 ["constructor"](){ return nonconstructor_sigil; } |
| 1081 constructor(){ return constructor_sigil; } |
| 1082 } |
| 1083 assertEquals(new FollowingConstructor, constructor_sigil); |
| 1084 assertEquals((new FollowingConstructor).constructor(), nonconstructor_sigil); |
| 1085 })(); |
OLD | NEW |