OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-debug-as debug --harmony-classes | 5 // Flags: --expose-debug-as debug --harmony-classes |
6 | 6 |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
9 var Debug = debug.Debug | 9 var Debug = debug.Debug |
10 var done, stepCount; | 10 var done, stepCount; |
11 | 11 |
12 function listener(event, execState, eventData, data) { | 12 function listener(event, execState, eventData, data) { |
13 if (event == Debug.DebugEvent.Break) { | 13 if (event == Debug.DebugEvent.Break) { |
14 if (!done) { | 14 if (!done) { |
15 execState.prepareStep(Debug.StepAction.StepInto); | 15 execState.prepareStep(Debug.StepAction.StepInto); |
16 var s = execState.frame().sourceLineText(); | 16 var s = execState.frame().sourceLineText(); |
17 assertTrue(s.indexOf('// ' + stepCount + '.') !== -1); | 17 assertTrue(s.indexOf('// ' + stepCount + '.') !== -1); |
18 stepCount++; | 18 stepCount++; |
19 } | 19 } |
20 } | 20 } |
21 }; | 21 }; |
22 | 22 |
23 Debug.setListener(listener); | 23 Debug.setListener(listener); |
24 | 24 |
25 | 25 |
26 class Base { | 26 class Base { |
27 constructor() { | 27 constructor() { // 1. |
Michael Starzinger
2015/04/10 11:49:12
Arv: Can you please advise on this change. Does th
Michael Starzinger
2015/04/10 13:56:40
OK, I managed to find this regression and fixed it
| |
28 var x = 1; // 1. | 28 var x = 1; // 2. |
29 var y = 2; // 2. | 29 var y = 2; // 3. |
30 done = true; // 3. | 30 done = true; // 4. |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 class Derived extends Base {} | 34 class Derived extends Base {} |
35 | 35 |
36 | 36 |
37 (function TestBreakPointInConstructor() { | 37 (function TestBreakPointInConstructor() { |
38 done = false; | 38 done = false; |
39 stepCount = 1; | 39 stepCount = 1; |
40 var bp = Debug.setBreakPoint(Base, 0); | 40 var bp = Debug.setBreakPoint(Base, 0); |
41 | 41 |
42 new Base(); | 42 new Base(); |
43 assertEquals(4, stepCount); | 43 assertEquals(5, stepCount); |
44 | 44 |
45 Debug.clearBreakPoint(bp); | 45 Debug.clearBreakPoint(bp); |
46 })(); | 46 })(); |
47 | 47 |
48 | 48 |
49 (function TestDefaultConstructor() { | 49 (function TestDefaultConstructor() { |
50 done = false; | 50 done = false; |
51 stepCount = 1; | 51 stepCount = 1; |
52 | 52 |
53 var bp = Debug.setBreakPoint(Base, 0); | 53 var bp = Debug.setBreakPoint(Base, 0); |
54 new Derived(); | 54 new Derived(); |
55 assertEquals(4, stepCount); | 55 assertEquals(5, stepCount); |
56 | 56 |
57 Debug.clearBreakPoint(bp); | 57 Debug.clearBreakPoint(bp); |
58 })(); | 58 })(); |
59 | 59 |
60 | 60 |
61 (function TestStepInto() { | 61 (function TestStepInto() { |
62 done = false; | 62 done = false; |
63 stepCount = 0; | 63 stepCount = 0; |
64 | 64 |
65 function f() { | 65 function f() { |
66 new Derived(); // 0. | 66 new Derived(); // 0. |
67 } | 67 } |
68 | 68 |
69 var bp = Debug.setBreakPoint(f, 0); | 69 var bp = Debug.setBreakPoint(f, 0); |
70 f(); | 70 f(); |
71 assertEquals(4, stepCount); | 71 assertEquals(5, stepCount); |
72 | 72 |
73 Debug.clearBreakPoint(bp); | 73 Debug.clearBreakPoint(bp); |
74 })(); | 74 })(); |
75 | 75 |
76 | 76 |
77 (function TestExtraIndirection() { | 77 (function TestExtraIndirection() { |
78 done = false; | 78 done = false; |
79 stepCount = 0; | 79 stepCount = 0; |
80 | 80 |
81 class Derived2 extends Derived {} | 81 class Derived2 extends Derived {} |
82 | 82 |
83 function f() { | 83 function f() { |
84 new Derived2(); // 0. | 84 new Derived2(); // 0. |
85 } | 85 } |
86 | 86 |
87 var bp = Debug.setBreakPoint(f, 0); | 87 var bp = Debug.setBreakPoint(f, 0); |
88 f(); | 88 f(); |
89 assertEquals(4, stepCount); | 89 assertEquals(5, stepCount); |
90 | 90 |
91 Debug.clearBreakPoint(bp); | 91 Debug.clearBreakPoint(bp); |
92 })(); | 92 })(); |
93 | 93 |
94 | 94 |
95 (function TestBoundClass() { | 95 (function TestBoundClass() { |
96 done = false; | 96 done = false; |
97 stepCount = 0; | 97 stepCount = 0; |
98 | 98 |
99 var bound = Derived.bind(null); | 99 var bound = Derived.bind(null); |
100 | 100 |
101 function f() { | 101 function f() { |
102 new bound(); // 0. | 102 new bound(); // 0. |
103 } | 103 } |
104 | 104 |
105 var bp = Debug.setBreakPoint(f, 0); | 105 var bp = Debug.setBreakPoint(f, 0); |
106 f(); | 106 f(); |
107 assertEquals(4, stepCount); | 107 assertEquals(5, stepCount); |
108 | 108 |
109 Debug.clearBreakPoint(bp); | 109 Debug.clearBreakPoint(bp); |
110 })(); | 110 })(); |
111 | 111 |
112 | 112 |
113 Debug.setListener(null); | 113 Debug.setListener(null); |
OLD | NEW |