| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 --harmony-new-target --harmony-reflect | 5 // Flags: --harmony-classes --harmony-new-target --harmony-reflect |
| 6 // Flags: --harmony-rest-parameters --harmony-arrow-functions | 6 // Flags: --harmony-rest-parameters --harmony-arrow-functions |
| 7 | 7 |
| 8 | 8 |
| 9 (function TestClass() { | 9 (function TestClass() { |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 constructor(expected) { | 149 constructor(expected) { |
| 150 super(expected); | 150 super(expected); |
| 151 assertInstanceof(this, RegExp); | 151 assertInstanceof(this, RegExp); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 assertInstanceof(new Derived2(Derived2), RegExp); | 154 assertInstanceof(new Derived2(Derived2), RegExp); |
| 155 assertInstanceof(new Derived2(Derived2, 'extra'), RegExp); | 155 assertInstanceof(new Derived2(Derived2, 'extra'), RegExp); |
| 156 })(); | 156 })(); |
| 157 | 157 |
| 158 | 158 |
| 159 /* | |
| 160 // TODO(arv): Reflect.construct does not work correctly with a third argument. | |
| 161 (function TestReflectConstruct() { | 159 (function TestReflectConstruct() { |
| 162 var calls = 0; | 160 var calls = 0; |
| 163 function f(expected) { | 161 function f(expected) { |
| 164 calls++; | 162 calls++; |
| 165 assertEquals(expected, new.target); | 163 assertEquals(expected, new.target); |
| 166 } | 164 } |
| 167 | 165 |
| 168 var o = Reflect.construct(f, [f]); | 166 var o = Reflect.construct(f, [f]); |
| 169 assertEquals(Object.getPrototypeOf(o), f.prototype); | 167 assertEquals(Object.getPrototypeOf(o), f.prototype); |
| 170 o = Reflect.construct(f, [f, 'extra']); | 168 o = Reflect.construct(f, [f, 'extra']); |
| 171 assertEquals(Object.getPrototypeOf(o), f.prototype); | 169 assertEquals(Object.getPrototypeOf(o), f.prototype); |
| 172 assertEquals(2, calls); | 170 assertEquals(2, calls); |
| 173 | 171 |
| 174 calls = 0; | 172 calls = 0; |
| 175 o = Reflect.construct(f, [f], f); | 173 o = Reflect.construct(f, [f], f); |
| 176 assertEquals(Object.getPrototypeOf(o), f.prototype); | 174 assertEquals(Object.getPrototypeOf(o), f.prototype); |
| 177 o = Reflect.construct(f, [f, 'extra'], f); | 175 o = Reflect.construct(f, [f, 'extra'], f); |
| 178 assertEquals(Object.getPrototypeOf(o), f.prototype); | 176 assertEquals(Object.getPrototypeOf(o), f.prototype); |
| 179 assertEquals(2, calls); | 177 assertEquals(2, calls); |
| 180 | 178 |
| 181 | 179 |
| 182 function g() {} | 180 function g() {} |
| 183 calls = 0; | 181 calls = 0; |
| 184 o = Reflect.construct(f, [g], g); | 182 o = Reflect.construct(f, [g], g); |
| 185 assertEquals(Object.getPrototypeOf(o), g.prototype); | 183 assertEquals(Object.getPrototypeOf(o), g.prototype); |
| 186 o = Reflect.construct(f, [g, 'extra'], g); | 184 o = Reflect.construct(f, [g, 'extra'], g); |
| 187 assertEquals(Object.getPrototypeOf(o), g.prototype); | 185 assertEquals(Object.getPrototypeOf(o), g.prototype); |
| 188 assertEquals(2, calls); | 186 assertEquals(2, calls); |
| 189 })(); | 187 })(); |
| 190 */ | |
| 191 | 188 |
| 192 | 189 |
| 193 (function TestRestParametersFunction() { | 190 (function TestRestParametersFunction() { |
| 194 function f(...rest) { | 191 function f(...rest) { |
| 195 assertEquals(rest[0], new.target); | 192 assertEquals(rest[0], new.target); |
| 196 } | 193 } |
| 197 | 194 |
| 198 assertInstanceof(new f(f), f); | 195 assertInstanceof(new f(f), f); |
| 199 assertInstanceof(new f(f, 'extra'), f); | 196 assertInstanceof(new f(f, 'extra'), f); |
| 200 })(); | 197 })(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 a0 = 1; | 361 a0 = 1; |
| 365 a1 = 2; | 362 a1 = 2; |
| 366 f(1, 2); | 363 f(1, 2); |
| 367 | 364 |
| 368 length = 3; | 365 length = 3; |
| 369 a0 = 1; | 366 a0 = 1; |
| 370 a1 = 2; | 367 a1 = 2; |
| 371 a2 = 3; | 368 a2 = 3; |
| 372 f(1, 2, 3); | 369 f(1, 2, 3); |
| 373 })(); | 370 })(); |
| OLD | NEW |