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

Side by Side Diff: test/mjsunit/harmony/debug-async-break-on-stack.js

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

Powered by Google App Engine
This is Rietveld 408576698