Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: test/mjsunit/harmony/promise-species.js

Issue 2096933002: Remove all harmony runtime flags which shipped in M51 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/harmony/iterator-close.js ('k') | test/mjsunit/harmony/regexp-change-exec.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-species --allow-natives-syntax
6
7 // Test that Promises use @@species appropriately
8
9 // Another constructor with no species will not be instantiated
10 var test = new Promise(function(){});
11 var bogoCount = 0;
12 function bogusConstructor() { bogoCount++; }
13 test.constructor = bogusConstructor;
14 assertTrue(Promise.resolve(test) instanceof Promise);
15 assertFalse(Promise.resolve(test) instanceof bogusConstructor);
16 // Tests that chromium:575314 is fixed thoroughly
17 Promise.resolve(test).catch(e => %AbortJS("Error " + e)).then(() => {
18 if (bogoCount != 0) %AbortJS("bogoCount was " + bogoCount + " should be 0");
19 });
20
21 // If there is a species, it will be instantiated
22 // @@species will be read exactly once, and the constructor is called with a
23 // function
24 var count = 0;
25 var params;
26 class MyPromise extends Promise {
27 constructor(...args) {
28 super(...args);
29 params = args;
30 }
31 static get [Symbol.species]() {
32 count++
33 return this;
34 }
35 }
36
37 var myPromise = MyPromise.resolve().then();
38 assertEquals(1, count);
39 assertEquals(1, params.length);
40 assertEquals('function', typeof(params[0]));
41 assertTrue(myPromise instanceof MyPromise);
42 assertTrue(myPromise instanceof Promise);
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/iterator-close.js ('k') | test/mjsunit/harmony/regexp-change-exec.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698