blob: b27b03d28bfb75cb0763c7856a21ae5cba01933e [file] [log] [blame]
Ben Murdochda12d292016-06-02 14:46:10 +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
6
7// Test we break at every assignment in a var-statement with multiple
8// variable declarations.
9
10var exception = null;
11var log = []
12
13function f() {
14 var l1 = 1, // l
15 l2, // m
16 l3 = 3; // n
17 let l4, // o
18 l5 = 5, // p
19 l6 = 6; // q
20 const l7 = 7, // r
21 l8 = 8, // s
22 l9 = 9; // t
23 return 0; // u
24} // v
25
26function listener(event, exec_state, event_data, data) {
27 if (event != Debug.DebugEvent.Break) return;
28 try {
29 var line = exec_state.frame(0).sourceLineText();
30 var col = exec_state.frame(0).sourceColumn();
31 print(line);
32 var match = line.match(/\/\/ (\w)$/);
33 assertEquals(2, match.length);
34 log.push(match[1] + col);
35 if (match[1] != "v") {
36 exec_state.prepareStep(Debug.StepAction.StepIn);
37 }
38 } catch (e) {
39 exception = e;
40 }
41}
42
43var Debug = debug.Debug;
44Debug.setListener(listener);
45
46debugger; // a
47var g1 = 1, // b
48 g2 = 2, // c
49 g3; // d
50let g4 = 4, // e
51 g5, // f
52 g6 = 6; // g
53const g7 = 7, // h
54 g8 = 8, // i
55 g9 = f(); // j
56
57Debug.setListener(null);
58
59assertNull(exception);
60
61// Note that let declarations, if not explicitly initialized, implicitly
62// initialize to undefined.
63
64var expected = [
65 "a0", // debugger statement
66 "b9","c9", // global var
67 "e9","f4","g9", // global let
68 "h11","i11","j11", // global const
69 "l11","n11", // local var
70 "o6","p11","q11", // local let
71 "r13","s13","t13", // local const
72 "u2","v0", // return
73];
74assertEquals(expected, log);