| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 var exception = null; | |
| 7 var Debug = debug.Debug; | |
| 8 var break_count = 0; | |
| 9 | |
| 10 function listener(event, exec_state, event_data, data) { | |
| 11 if (event != Debug.DebugEvent.Break) return; | |
| 12 try { | |
| 13 var source = exec_state.frame(0).sourceLineText(); | |
| 14 print(source, break_count); | |
| 15 assertTrue(source.indexOf(`B${break_count++}`) > 0); | |
| 16 if (source.indexOf("assertEquals") > 0) { | |
| 17 exec_state.prepareStep(Debug.StepAction.StepNext); | |
| 18 } else { | |
| 19 exec_state.prepareStep(Debug.StepAction.StepIn); | |
| 20 } | |
| 21 } catch (e) { | |
| 22 exception = e; | |
| 23 print(e); | |
| 24 } | |
| 25 }; | |
| 26 | |
| 27 Debug.setListener(listener); | |
| 28 | |
| 29 var id = x => x; // B9 B10 B36 B37 | |
| 30 | |
| 31 function test() { | |
| 32 debugger; // B0 | |
| 33 function fx1([ | |
| 34 a, // B2 | |
| 35 b // B3 | |
| 36 ]) { | |
| 37 assertEquals([1, 2], [a, b]); // B4 | |
| 38 } // B5 | |
| 39 fx1([1, 2, 3]); // B1 | |
| 40 | |
| 41 function f2([ | |
| 42 a, // B7 | |
| 43 b = id(3) // B8 | |
| 44 ]) { | |
| 45 assertEquals([4, 3], [a, b]); // B11 | |
| 46 } // B12 | |
| 47 f2([4]); // B6 | |
| 48 | |
| 49 function f3({ | |
| 50 x: a, // B14 | |
| 51 y: b // B15 | |
| 52 }) { | |
| 53 assertEquals([5, 6], [a, b]); // B16 | |
| 54 } // B17 | |
| 55 f3({y: 6, x: 5}); // B13 | |
| 56 | |
| 57 function f4([ | |
| 58 a, // B19 | |
| 59 { | |
| 60 b, // B20 | |
| 61 c, // B21 | |
| 62 } | |
| 63 ]) { | |
| 64 assertEquals([2, 4, 6], [a, b, c]); // B22 | |
| 65 } // B23 | |
| 66 f4([2, {c: 6, b: 4}]); // B18 | |
| 67 | |
| 68 function f5([ | |
| 69 { | |
| 70 a, // B25 | |
| 71 b = 7 // B26 | |
| 72 }, | |
| 73 c = 3 // B27 | |
| 74 ] = [{a:1}]) { | |
| 75 assertEquals([1, 7, 3], [a, b, c]); // B28 | |
| 76 } // B29 | |
| 77 f5(); // B24 | |
| 78 | |
| 79 var name = "x"; // B30 | |
| 80 function f6({ | |
| 81 [id(name)]: a, // B34 B35 | |
| 82 b = a // B38 | |
| 83 }) { | |
| 84 assertEquals([9, 9], [a, b]); // B39 | |
| 85 } // B40 | |
| 86 var o6 = {}; // B31 | |
| 87 o6[name] = 9; // B32 | |
| 88 f6(o6); // B33 | |
| 89 | |
| 90 try { | |
| 91 throw [3, 4]; // B41 | |
| 92 } catch ([ | |
| 93 a, // B42 | |
| 94 b, // B43 | |
| 95 c = 6 // B44 | |
| 96 ]) { | |
| 97 assertEquals([3, 4, 6], [a, b, c]); // B45 | |
| 98 } | |
| 99 | |
| 100 var { | |
| 101 x: a, // B46 | |
| 102 y: b = 9 // B47 | |
| 103 } = { x: 4 }; | |
| 104 assertEquals([4, 9], [a, b]); // B48 | |
| 105 } // B49 | |
| 106 | |
| 107 test(); | |
| 108 Debug.setListener(null); // B50 | |
| 109 assertNull(exception); | |
| OLD | NEW |