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

Side by Side Diff: test/mjsunit/harmony/debug-async-function-async-task-event.js

Issue 2037653002: Some new/fixed async tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adjust test expectations for Sathya's optimization Created 4 years, 6 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/es6/debug-promises/async-task-event.js ('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
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2016 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: --expose-debug-as debug 5 // Flags: --harmony-async-await --expose-debug-as debug --allow-natives-syntax
6 6
7 Debug = debug.Debug; 7 Debug = debug.Debug;
8 8
9 var base_id = -1; 9 var base_id = -1;
10 var exception = null; 10 var exception = null;
11 var expected = [ 11 var expected = [
12 "enqueue #1", 12 "enqueue #1",
13 "willHandle #1", 13 "willHandle #1",
14 "then #1", 14 "then #1",
15 "enqueue #2", 15 "enqueue #2",
16 "enqueue #3",
16 "didHandle #1", 17 "didHandle #1",
17 "willHandle #2", 18 "willHandle #2",
18 "then #2", 19 "then #2",
19 "enqueue #3",
20 "didHandle #2", 20 "didHandle #2",
21 "willHandle #3", 21 "willHandle #3",
22 "didHandle #3" 22 "enqueue #4",
23 "didHandle #3",
24 "willHandle #4",
25 "didHandle #4",
23 ]; 26 ];
24 27
25 function assertLog(msg) { 28 function assertLog(msg) {
26 print(msg); 29 print(msg);
27 assertTrue(expected.length > 0); 30 assertTrue(expected.length > 0);
28 assertEquals(expected.shift(), msg); 31 assertEquals(expected.shift(), msg);
29 if (!expected.length) { 32 if (!expected.length) {
30 Debug.setListener(null); 33 Debug.setListener(null);
31 } 34 }
32 } 35 }
33 36
34 function listener(event, exec_state, event_data, data) { 37 function listener(event, exec_state, event_data, data) {
35 if (event != Debug.DebugEvent.AsyncTaskEvent) return; 38 if (event != Debug.DebugEvent.AsyncTaskEvent) return;
36 try { 39 try {
37 if (base_id < 0) 40 if (base_id < 0)
38 base_id = event_data.id(); 41 base_id = event_data.id();
39 var id = event_data.id() - base_id + 1; 42 var id = event_data.id() - base_id + 1;
40 assertEquals("Promise.resolve", event_data.name()); 43 assertTrue("Promise.resolve" == event_data.name() ||
44 "PromiseResolveThenableJob" == event_data.name());
41 assertLog(event_data.type() + " #" + id); 45 assertLog(event_data.type() + " #" + id);
42 } catch (e) { 46 } catch (e) {
43 print(e + e.stack) 47 print(e + e.stack)
44 exception = e; 48 exception = e;
45 } 49 }
46 } 50 }
47 51
48 Debug.setListener(listener); 52 Debug.setListener(listener);
49 53
50 var resolver; 54 var resolver;
51 var p = new Promise(function(resolve, reject) { 55 var p = new Promise(function(resolve, reject) {
52 resolver = resolve; 56 resolver = resolve;
53 }); 57 });
54 p.then(function() { 58
59 async function main() {
60 await p;
55 assertLog("then #1"); 61 assertLog("then #1");
56 }).then(function() { 62 await undefined;
57 assertLog("then #2"); 63 assertLog("then #2");
58 }); 64 }
65 main();
59 resolver(); 66 resolver();
60 67
68 %RunMicrotasks();
69
61 assertNull(exception); 70 assertNull(exception);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises/async-task-event.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698