| 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-species --allow-natives-syntax | 5 // Flags: --allow-natives-syntax |
| 6 | 6 |
| 7 // Test that Promises use @@species appropriately | 7 // Test that Promises use @@species appropriately |
| 8 | 8 |
| 9 // Another constructor with no species will not be instantiated | 9 // Another constructor with no species will not be instantiated |
| 10 var test = new Promise(function(){}); | 10 var test = new Promise(function(){}); |
| 11 var bogoCount = 0; | 11 var bogoCount = 0; |
| 12 function bogusConstructor() { bogoCount++; } | 12 function bogusConstructor() { bogoCount++; } |
| 13 test.constructor = bogusConstructor; | 13 test.constructor = bogusConstructor; |
| 14 assertTrue(Promise.resolve(test) instanceof Promise); | 14 assertTrue(Promise.resolve(test) instanceof Promise); |
| 15 assertFalse(Promise.resolve(test) instanceof bogusConstructor); | 15 assertFalse(Promise.resolve(test) instanceof bogusConstructor); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 33 return this; | 33 return this; |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 var myPromise = MyPromise.resolve().then(); | 37 var myPromise = MyPromise.resolve().then(); |
| 38 assertEquals(1, count); | 38 assertEquals(1, count); |
| 39 assertEquals(1, params.length); | 39 assertEquals(1, params.length); |
| 40 assertEquals('function', typeof(params[0])); | 40 assertEquals('function', typeof(params[0])); |
| 41 assertTrue(myPromise instanceof MyPromise); | 41 assertTrue(myPromise instanceof MyPromise); |
| 42 assertTrue(myPromise instanceof Promise); | 42 assertTrue(myPromise instanceof Promise); |
| OLD | NEW |