OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 var source = ` | |
6 function test() { | |
7 // for loops | |
8 for (var i = 0; i < 128; ++i) { | |
9 } | |
10 for (var a of array) { | |
11 } | |
12 for (var a of [1,2,3]) { | |
dgozman
2017/02/23 02:03:29
for (var a in {x:2})
kozy
2017/02/27 17:37:58
Done.
| |
13 } | |
14 for (var i = boo1(); i != boo2(); i += boo3()) { | |
15 } | |
16 // switch | |
17 switch(val) { | |
18 case 1: break; | |
19 case 2: return; | |
20 } | |
21 switch(boo1()) { | |
22 default: break; | |
23 } | |
24 // nested functions | |
25 function nested1() {} | |
dgozman
2017/02/23 02:03:29
Let's do double-nested as well.
kozy
2017/02/27 17:37:58
Done.
| |
26 function nested2() { return 42; } | |
dgozman
2017/02/23 02:03:29
function nested3() { return; }
kozy
2017/02/27 17:37:58
Done.
| |
27 // arrow function + assignment | |
28 var a = () => 42; | |
29 // var | |
30 var b1 = 2; | |
31 var b2 = 1 + 2; | |
32 var b3 = ++b2; | |
33 var b4 = boo4() + boo5(); | |
34 // let | |
35 let a1 = 1; | |
36 let a2 = a1 + 2; | |
37 let a3 = boo3() + boo4(); | |
38 // const | |
39 const c1 = 1; | |
40 // while loops | |
41 while (i < boo5()) { | |
42 boo6(); | |
43 break; | |
44 } | |
45 // continue | |
46 while (i) { | |
47 ++i; | |
48 continue; | |
49 } | |
50 // debugger | |
51 debugger; | |
52 // do | |
dgozman
2017/02/23 02:03:29
Forgot about if and with constructions, and also g
kozy
2017/02/27 17:37:58
Done.
| |
53 do { | |
54 boo7(); | |
55 } while(boo5() + boo6()); | |
56 // try | |
57 try { | |
58 throw new Error(); | |
59 } catch (e) { | |
60 boo2(); | |
61 } finally { | |
62 boo1(); | |
63 } | |
64 // obj literal | |
65 var obj = { | |
66 prop: 2 | |
67 }; | |
68 // arrow functions | |
69 Promise.resolve().then(() => 42) | |
70 .then(a => a++) | |
71 .then(a => a()) | |
72 .then(a => { boo1(); boo2(); }); | |
73 // classes | |
74 class Cat { | |
75 constructor(name) { | |
76 this.name = name; | |
77 } | |
78 | |
79 speak() { | |
80 } | |
81 } | |
82 class Lion extends Cat { | |
83 constructor(name) { | |
84 super(name); | |
85 } | |
86 | |
87 speak() { | |
88 super.speak(); | |
89 } | |
90 } | |
91 // other expressions | |
92 obj.a.b().c = obj.a().b.c(); | |
93 1 + 2; | |
94 ({}).a = 42; | |
95 ++a; | |
96 boo() + foo(); | |
97 // async await | |
98 async function async1() { | |
99 await Promise.resolve().then(() => 42); | |
100 await async2(); | |
101 } | |
102 async function async2() { | |
103 return 42; | |
104 } | |
105 } | |
dgozman
2017/02/23 02:03:29
Let's also have something complex like
foo(boo1()
kozy
2017/02/27 17:37:58
Done.
dgozman
2017/02/27 18:01:10
Forgot about this or did I miss it?
kozy
2017/02/27 18:54:19
lost during migration to test from step-into :( ad
| |
106 //# sourceURL=test.js`; | |
107 InspectorTest.addScript(source); | |
108 | |
109 Protocol.Debugger.onceScriptParsed() | |
110 .then(message => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumbe r: 0, columnNumber : 0, scriptId: message.params.scriptId }})) | |
111 .then(dumpAllLocations) | |
112 .then(InspectorTest.completeTest); | |
113 Protocol.Debugger.enable(); | |
114 | |
115 function dumpAllLocations(message) { | |
116 if (message.error) { | |
117 InspectorTest.logMessage(message); | |
118 return; | |
119 } | |
120 var lines = source.split('\n'); | |
121 var locations = message.result.locations.sort((loc1, loc2) => { | |
122 if (loc2.lineNumber !== loc1.lineNumber) return loc2.lineNumber - loc1.lineN umber; | |
123 return loc2.columnNumber - loc1.columnNumber; | |
124 }); | |
125 for (var location of locations) { | |
126 var line = lines[location.lineNumber]; | |
127 line = line.slice(0, location.columnNumber) + '#' + line.slice(location.colu mnNumber); | |
128 lines[location.lineNumber] = line; | |
129 } | |
130 InspectorTest.log(lines.join('\n')); | |
131 return message; | |
132 } | |
OLD | NEW |