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