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

Side by Side Diff: test/mjsunit/regress/regress-3641.js

Issue 1488783002: Clean up promises and fix an edge case bug (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor code cleanup; disable some soon-to-be-obsolete mjsunit tests Created 5 years 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/mjsunit.status ('k') | no next file » | 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: --allow-natives-syntax
6
7 // If a Promise's then method is overridden, that should be respected
8 // even if the promise is already resolved. x's resolution function is
9 // only called by Promise.resolve(); there shouldn't be a resolution
10 // check before when calling x.then.
11
12
13 // Async assert framework copied from mjsunit/es6/promises.js
14
15 var asyncAssertsExpected = 0;
16
17 function assertAsyncRan() { ++asyncAssertsExpected }
18
19 function assertLater(f, name) {
20 assertFalse(f()); // should not be true synchronously
21 ++asyncAssertsExpected;
22 var iterations = 0;
23 function runAssertion() {
24 if (f()) {
25 print(name, "succeeded");
26 --asyncAssertsExpected;
27 } else if (iterations++ < 10) {
28 %EnqueueMicrotask(runAssertion);
29 } else {
30 %AbortJS(name + " FAILED!");
31 }
32 }
33 %EnqueueMicrotask(runAssertion);
34 }
35
36 function assertAsyncDone(iteration) {
37 var iteration = iteration || 0;
38 %EnqueueMicrotask(function() {
39 if (asyncAssertsExpected === 0)
40 assertAsync(true, "all")
41 else if (iteration > 10) // Shouldn't take more.
42 assertAsync(false, "all... " + asyncAssertsExpected)
43 else
44 assertAsyncDone(iteration + 1)
45 });
46 }
47
48 // End async assert framework
49
50 var y;
51 var x = Promise.resolve();
52 x.then = () => { y = true; }
53 Promise.resolve().then(() => x);
54 assertLater(() => y === true, "y === true");
55
56 assertAsyncDone();
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698