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