OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax |
| 6 |
| 7 (function modifyArrayIterator() { |
| 8 'use strict'; |
| 9 |
| 10 class Point { |
| 11 constructor(x, y) { |
| 12 this.x = x; |
| 13 this.y = y; |
| 14 } |
| 15 } |
| 16 |
| 17 class RestPoint extends Point { |
| 18 constructor(...args) { |
| 19 super(...args); |
| 20 } |
| 21 } |
| 22 |
| 23 function testRestPoint(x, y) { |
| 24 return new RestPoint(x, y); |
| 25 } |
| 26 testRestPoint(1, 2); |
| 27 testRestPoint(1, 2); |
| 28 % OptimizeFunctionOnNextCall(testRestPoint); |
| 29 var r = testRestPoint(1, 2); |
| 30 |
| 31 assertInstanceof(r, RestPoint); |
| 32 assertInstanceof(r, Point); |
| 33 assertEquals(1, r.x); |
| 34 assertEquals(2, r.y); |
| 35 |
| 36 Object.defineProperty(Array.prototype, Symbol.iterator, { |
| 37 value: function* |
| 38 () { |
| 39 yield 3; |
| 40 yield 4; |
| 41 }, |
| 42 configurable: true |
| 43 }); |
| 44 |
| 45 var r2 = testRestPoint(1, 2); |
| 46 |
| 47 assertInstanceof(r2, RestPoint); |
| 48 assertInstanceof(r2, Point); |
| 49 assertEquals(3, r2.x); |
| 50 assertEquals(4, r2.y); |
| 51 })(); |
OLD | NEW |