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

Side by Side Diff: test/debugger/debug/harmony/debug-async-break.js

Issue 2621173002: Remove --harmony-async-await runtime flag (Closed)
Patch Set: Update test ref Created 3 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-async-await
6
7 var Debug = debug.Debug;
8
9 function assertEqualsAsync(expected, run, msg) {
10 var actual;
11 var hadValue = false;
12 var hadError = false;
13 var promise = run();
14
15 if (typeof promise !== "object" || typeof promise.then !== "function") {
16 throw new MjsUnitAssertionError(
17 "Expected " + run.toString() +
18 " to return a Promise, but it returned " + promise);
19 }
20
21 promise.then(function(value) { hadValue = true; actual = value; },
22 function(error) { hadError = true; actual = error; });
23
24 assertFalse(hadValue || hadError);
25
26 %RunMicrotasks();
27
28 if (hadError) throw actual;
29
30 assertTrue(
31 hadValue, "Expected '" + run.toString() + "' to produce a value");
32
33 assertEquals(expected, actual, msg);
34 }
35
36 var break_count = 0;
37 var exception = null;
38
39 function listener(event, exec_state, event_data, data) {
40 if (event != Debug.DebugEvent.Break) return;
41 try {
42 break_count++;
43 var line = exec_state.frame(0).sourceLineText();
44 assertTrue(line.indexOf(`B${break_count}`) > 0);
45 } catch (e) {
46 exception = e;
47 }
48 }
49
50 Debug.setListener(listener);
51
52 async function g() {
53 throw 1;
54 }
55
56 async function f() {
57 try {
58 await g(); // B1
59 } catch (e) {}
60 assertEquals(2, break_count); // B2
61 return 1; // B3
62 }
63
64 Debug.setBreakPoint(f, 2);
65 Debug.setBreakPoint(f, 4);
66 Debug.setBreakPoint(f, 5);
67
68 f();
69
70 %RunMicrotasks();
71
72 assertEqualsAsync(3, async () => break_count);
73 assertEqualsAsync(null, async () => exception);
74
75 Debug.setListener(null);
OLDNEW
« no previous file with comments | « test/debugger/debug/harmony/async-function-debug-scopes.js ('k') | test/debugger/debug/harmony/debug-async-break-on-stack.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698