Chromium Code Reviews| 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 print(s); | |
| 18 assertTrue(s.indexOf('// ' + stepCount + '.') !== -1); | |
| 19 stepCount++; | |
| 20 } | |
| 21 } | |
| 22 }; | |
| 23 | |
| 24 Debug.setListener(listener); | |
| 25 | |
| 26 | |
| 27 class Base { | |
| 28 constructor() { | |
| 29 var x = 1; // 1. | |
| 30 var y = 2; // 2. | |
| 31 done = true; // 3. | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 class Derived extends Base {} | |
| 36 | |
| 37 | |
| 38 (function TestBreakPointInConstructor() { | |
| 39 done = false; | |
| 40 stepCount = 1; | |
| 41 var bp = Debug.setBreakPoint(Base, 0); | |
|
Dmitry Lomov (no reviews)
2014/11/14 17:19:15
You can just use 'debugger;' in the places where y
arv (Not doing code reviews)
2014/11/14 17:24:00
True. In this specific case, I wanted to make sure
Dmitry Lomov (no reviews)
2014/11/14 17:30:59
Ah right, gotcha. I'll leave it up to you.
| |
| 42 | |
| 43 new Base(); | |
| 44 assertEquals(4, stepCount); | |
| 45 | |
| 46 Debug.clearBreakPoint(bp); | |
| 47 })(); | |
| 48 | |
| 49 | |
| 50 (function TestDefaultConstructor() { | |
| 51 done = false; | |
| 52 stepCount = 1; | |
| 53 | |
| 54 var bp = Debug.setBreakPoint(Base, 0); | |
| 55 new Derived(); | |
| 56 assertEquals(4, stepCount); | |
| 57 | |
| 58 Debug.clearBreakPoint(bp); | |
| 59 })(); | |
| 60 | |
| 61 | |
| 62 (function TestStepInto() { | |
| 63 done = false; | |
| 64 stepCount = 0; | |
| 65 | |
| 66 function f() { | |
| 67 new Derived(); // 0. | |
| 68 } | |
| 69 | |
| 70 var bp = Debug.setBreakPoint(f, 0); | |
| 71 f(); | |
| 72 assertEquals(4, stepCount); | |
| 73 | |
| 74 Debug.clearBreakPoint(bp); | |
| 75 })(); | |
| 76 | |
| 77 | |
| 78 (function TestExtraIndirection() { | |
| 79 done = false; | |
| 80 stepCount = 0; | |
| 81 | |
| 82 class Derived2 extends Derived {} | |
| 83 | |
| 84 function f() { | |
| 85 new Derived2(); // 0. | |
| 86 } | |
| 87 | |
| 88 var bp = Debug.setBreakPoint(f, 0); | |
| 89 f(); | |
| 90 assertEquals(4, stepCount); | |
| 91 | |
| 92 Debug.clearBreakPoint(bp); | |
| 93 })(); | |
| 94 | |
| 95 | |
| 96 (function TestBoundClass() { | |
| 97 done = false; | |
| 98 stepCount = 0; | |
| 99 | |
| 100 var bound = Derived.bind(null); | |
| 101 | |
| 102 function f() { | |
| 103 new bound(); // 0. | |
| 104 } | |
| 105 | |
| 106 var bp = Debug.setBreakPoint(f, 0); | |
| 107 f(); | |
| 108 assertEquals(4, stepCount); | |
| 109 | |
| 110 Debug.clearBreakPoint(bp); | |
| 111 })(); | |
| 112 | |
| 113 | |
| 114 Debug.setListener(null); | |
| OLD | NEW |