blob: 0a7de1a2a35e65d9f23e33244835f8b48cc7bf32 [file] [log] [blame]
Ben Murdoch61f157c2016-09-16 13:49:30 +01001// 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 --allow-natives-syntax --harmony-async-await
6
7var Debug = debug.Debug;
8var step_count = 0;
9
10function listener(event, execState, eventData, data) {
11 if (event != Debug.DebugEvent.Break) return;
12 try {
13 var line = execState.frame(0).sourceLineText();
14 print(line);
15 var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line);
16 assertEquals(step_count++, parseInt(expected_count));
17 if (step != "Continue") execState.prepareStep(Debug.StepAction[step]);
18 } catch (e) {
19 print(e, e.stack);
20 quit(1);
21 }
22}
23
24Debug.setListener(listener);
25
26var late_resolve;
27
28function g() {
29 return new Promise( // B3 StepIn
30 function(res, rej) {
31 late_resolve = res; // B4 StepIn
32 } // B5 StepIn
33 );
34} // B6 StepIn
35
36async function f() {
37 var a = 1;
38 debugger; // B0 StepNext
39 a += // B1 StepIn
40 await // B7 StepIn
41 g(); // B2 StepIn
42 return a; // B8 StepIn
43} // B9 Continue
44
45f().then(value => assertEquals(4, value));
46
47late_resolve(3);
48
49%RunMicrotasks();
50
51assertEquals(10, step_count);