OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 'use strict'; | |
8 | |
9 var Debug = debug.Debug | |
10 var done, stepCount; | |
11 var exception = null; | |
12 | |
13 function listener(event, execState, eventData, data) { | |
14 if (event != Debug.DebugEvent.Break) return; | |
15 try { | |
16 if (!done) { | |
17 execState.prepareStep(Debug.StepAction.StepIn); | |
18 var s = execState.frame().sourceLineText(); | |
19 assertTrue(s.indexOf('// ' + stepCount + '.') !== -1); | |
20 stepCount++; | |
21 } | |
22 } catch (e) { | |
23 exception = e; | |
24 } | |
25 }; | |
26 | |
27 Debug.setListener(listener); | |
28 | |
29 | |
30 class Base { | |
31 constructor() { | |
32 var x = 1; // 1. | |
33 var y = 2; // 2. | |
34 done = true; // 3. | |
35 } | |
36 } | |
37 | |
38 class Derived extends Base {} // 0. | |
39 | |
40 | |
41 (function TestBreakPointInConstructor() { | |
42 done = false; | |
43 stepCount = 1; | |
44 var bp = Debug.setBreakPoint(Base, 0); | |
45 | |
46 new Base(); | |
47 assertEquals(4, stepCount); | |
48 | |
49 Debug.clearBreakPoint(bp); | |
50 })(); | |
51 | |
52 | |
53 (function TestDefaultConstructor() { | |
54 done = false; | |
55 stepCount = 1; | |
56 | |
57 var bp = Debug.setBreakPoint(Base, 0); | |
58 new Derived(); | |
59 assertEquals(4, stepCount); | |
60 | |
61 Debug.clearBreakPoint(bp); | |
62 })(); | |
63 | |
64 | |
65 (function TestStepInto() { | |
66 done = false; | |
67 stepCount = -1; | |
68 | |
69 function f() { | |
70 new Derived(); // -1. | |
71 } | |
72 | |
73 var bp = Debug.setBreakPoint(f, 0); | |
74 f(); | |
75 assertEquals(4, stepCount); | |
76 | |
77 Debug.clearBreakPoint(bp); | |
78 })(); | |
79 | |
80 | |
81 (function TestExtraIndirection() { | |
82 done = false; | |
83 stepCount = -2; | |
84 | |
85 class Derived2 extends Derived {} // -1. | |
86 | |
87 function f() { | |
88 new Derived2(); // -2. | |
89 } | |
90 | |
91 var bp = Debug.setBreakPoint(f, 0); | |
92 f(); | |
93 assertEquals(4, stepCount); | |
94 | |
95 Debug.clearBreakPoint(bp); | |
96 })(); | |
97 | |
98 | |
99 (function TestBoundClass() { | |
100 done = false; | |
101 stepCount = -1; | |
102 | |
103 var bound = Derived.bind(null); | |
104 | |
105 function f() { | |
106 new bound(); // -1. | |
107 } | |
108 | |
109 var bp = Debug.setBreakPoint(f, 0); | |
110 f(); | |
111 assertEquals(4, stepCount); | |
112 | |
113 Debug.clearBreakPoint(bp); | |
114 })(); | |
115 | |
116 | |
117 Debug.setListener(null); | |
118 assertNull(exception); | |
OLD | NEW |