OLD | NEW |
1 Checks Debugger.getPossibleBreakpoints | 1 Checks Debugger.getPossibleBreakpoints |
2 // Copyright 2017 the V8 project authors. All rights reserved. | 2 // Copyright 2017 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 function testEval() { | 6 function testEval() { |
7 #eval('// comment only'); | 7 |C|eval('// comment only'); |
8 #eval('// comment only\n'); | 8 |C|eval('// comment only\n'); |
9 #} | 9 |R|} |
10 | 10 |
11 // function without return | 11 // function without return |
12 function procedure() { | 12 function procedure() { |
13 var a = #1; | 13 var a = |_|1; |
14 var b = #2; | 14 var b = |_|2; |
15 #} | 15 |R|} |
16 | 16 |
17 function testProcedure() { | 17 function testProcedure() { |
18 #procedure(); | 18 |C|procedure(); |
19 #} | 19 |R|} |
20 | 20 |
21 function returnTrue() { | 21 function returnTrue() { |
22 #return true; | 22 |_|return true; |
23 #} | 23 |R|} |
24 | 24 |
25 function testIf() { | 25 function testIf() { |
26 var a; | 26 var a; |
27 #if (true) #a = true; | 27 |_|if (true) |_|a = true; |
28 #if (!a) { | 28 |_|if (!a) { |
29 #a = true; | 29 |_|a = true; |
30 } else { | 30 } else { |
31 #a = false; | 31 |_|a = false; |
32 } | 32 } |
33 #if (#returnTrue()) { | 33 |_|if (|C|returnTrue()) { |
34 #a = false; | 34 |_|a = false; |
35 } else { | 35 } else { |
36 #a = true; | 36 |_|a = true; |
37 } | 37 } |
38 #} | 38 |R|} |
39 | 39 |
40 function emptyFunction() {#} | 40 function emptyFunction() {|R|} |
41 | 41 |
42 function testEmptyFunction() { | 42 function testEmptyFunction() { |
43 #emptyFunction(); | 43 |C|emptyFunction(); |
44 #} | 44 |R|} |
45 | 45 |
46 function twoArguments(a1, a2) { | 46 function twoArguments(a1, a2) { |
47 #} | 47 |R|} |
48 | 48 |
49 function testCallArguments() { | 49 function testCallArguments() { |
50 #twoArguments(#emptyFunction(), #emptyFunction()); | 50 |C|twoArguments(|C|emptyFunction(), |C|emptyFunction()); |
51 #} | 51 |R|} |
52 | 52 |
53 function testNested() { | 53 function testNested() { |
54 function nested1() { | 54 function nested1() { |
55 function nested2() { | 55 function nested2() { |
56 function nested3() { | 56 function nested3() { |
57 #} | 57 |R|} |
58 #nested3(); | 58 |C|nested3(); |
59 #return; | 59 |_|return; |
60 #} | 60 |R|} |
61 #return #nested2(); | 61 |_|return |C|nested2(); |
62 #} | 62 |R|} |
63 #nested1(); | 63 |C|nested1(); |
64 #} | 64 |R|} |
65 | 65 |
66 function return42() { | 66 function return42() { |
67 #return 42; | 67 |_|return 42; |
68 #} | 68 |R|} |
69 | 69 |
70 function returnCall() { | 70 function returnCall() { |
71 #return #return42(); | 71 |_|return |C|return42(); |
72 #} | 72 |R|} |
73 | 73 |
74 function testCallAtReturn() { | 74 function testCallAtReturn() { |
75 #return #returnCall(); | 75 |_|return |C|returnCall(); |
76 #} | 76 |R|} |
77 | 77 |
78 function returnObject() { | 78 function returnObject() { |
79 #return ({ foo: () => #42# }); | 79 |_|return ({ foo: () => |_|42|R| }); |
80 #} | 80 |R|} |
81 | 81 |
82 function testWith() { | 82 function testWith() { |
83 #with (#returnObject()) { | 83 |_|with (|C|returnObject()) { |
84 #foo(); | 84 |C|foo(); |
85 } | 85 } |
86 #with({}) { | 86 |_|with({}) { |
87 #return; | 87 |_|return; |
88 } | 88 } |
89 #} | 89 |R|} |
90 | 90 |
91 function testForLoop() { | 91 function testForLoop() { |
92 for (var i = #0; i #< 1; ++#i) {} | 92 for (var i = |_|0; i |_|< 1; ++|_|i) {} |
93 for (var i = #0; i #< 1; ++#i) #i; | 93 for (var i = |_|0; i |_|< 1; ++|_|i) |_|i; |
94 for (var i = #0; i #< 0; ++#i) {} | 94 for (var i = |_|0; i |_|< 0; ++|_|i) {} |
95 #} | 95 |R|} |
96 | 96 |
97 function testForOfLoop() { | 97 function testForOfLoop() { |
98 for (var k #of []) {} | 98 for (var k |C|of []) {} |
99 for (var k #of #[1]) #k; | 99 for (var k |C|of |_|[1]) |_|k; |
100 var a = #[]; | 100 var a = |_|[]; |
101 for (var k #of #a) {} | 101 for (var k |C|of |_|a) {} |
102 #} | 102 |R|} |
103 | 103 |
104 function testForInLoop() { | 104 function testForInLoop() { |
105 var o = #{}; | 105 var o = |_|{}; |
106 for (var #k in #o) {} | 106 for (var |_|k in |_|o) {} |
107 for (var #k in #o) #k; | 107 for (var |_|k in |_|o) |_|k; |
108 for (var #k in #{ a:1 }) {} | 108 for (var |_|k in |_|{ a:1 }) {} |
109 for (var #k in #{ a:1 }) #k; | 109 for (var |_|k in |_|{ a:1 }) |_|k; |
110 #} | 110 |R|} |
111 | 111 |
112 function testSimpleExpressions() { | 112 function testSimpleExpressions() { |
113 #1 + 2 + 3; | 113 |_|1 + 2 + 3; |
114 var a = #1; | 114 var a = |_|1; |
115 #++a; | 115 |_|++a; |
116 #a--; | 116 |_|a--; |
117 #} | 117 |R|} |
118 | 118 |
119 Object.defineProperty(this, 'getterFoo', { | 119 Object.defineProperty(this, 'getterFoo', { |
120 get: () => #return42# | 120 get: () => |_|return42|R| |
121 }); | 121 }); |
122 | 122 |
123 function testGetter() { | 123 function testGetter() { |
124 #getterFoo(); | 124 |C|getterFoo(); |
125 #} | 125 |R|} |
126 | 126 |
127 var obj = { | 127 var obj = { |
128 foo: () => (#{ | 128 foo: () => (|_|{ |
129 boo: () => #return42# | 129 boo: () => |_|return42|R| |
130 })# | 130 })|R| |
131 }; | 131 }; |
132 | 132 |
133 function testChainedCalls() { | 133 function testChainedCalls() { |
134 #obj.#foo().#boo()#(); | 134 |_|obj.|C|foo().|C|boo()|C|(); |
135 #} | 135 |R|} |
136 | 136 |
137 function testChainedWithNative() { | 137 function testChainedWithNative() { |
138 #Array.#from([1]).#concat([2]).#map(v => v #* 2#); | 138 |_|Array.|C|from([1]).|C|concat([2]).|C|map(v => v |_|* 2|R|); |
139 #} | 139 |R|} |
140 | 140 |
141 function testPromiseThen() { | 141 function testPromiseThen() { |
142 #return Promise.#resolve().#then(v => v #* 2#).#then(v => v #* 2#); | 142 |_|return Promise.|C|resolve().|C|then(v => v |_|* 2|R|).|C|then(v => v |_|* 2
|R|); |
143 #} | 143 |R|} |
144 | 144 |
145 function testSwitch() { | 145 function testSwitch() { |
146 for (var i = #0; i #< 3; ++#i) { | 146 for (var i = |_|0; i |_|< 3; ++|_|i) { |
147 #switch(i) { | 147 |_|switch(i) { |
148 case 0: #continue; | 148 case 0: |_|continue; |
149 case 1: #return42(); #break; | 149 case 1: |C|return42(); |_|break; |
150 default: #return; | 150 default: |_|return; |
151 } | 151 } |
152 } | 152 } |
153 #} | 153 |R|} |
154 | 154 |
155 function* idMaker() { | 155 function* idMaker() { |
156 #yield 1; | 156 |_|yield 1; |
157 #yield 2; | 157 |_|yield 2; |
158 #yield 3; | 158 |_|yield 3; |
159 #} | 159 |R|} |
160 | 160 |
161 function testGenerator() { | 161 function testGenerator() { |
162 var gen = #idMaker(); | 162 var gen = |C|idMaker(); |
163 #return42(); | 163 |C|return42(); |
164 #gen.#next().value; | 164 |_|gen.|C|next().value; |
165 #debugger; | 165 |D|debugger; |
166 #gen.#next().value; | 166 |_|gen.|C|next().value; |
167 #return42(); | 167 |C|return42(); |
168 #gen.#next().value; | 168 |_|gen.|C|next().value; |
169 #return42(); | 169 |C|return42(); |
170 #gen.#next().value; | 170 |_|gen.|C|next().value; |
171 #} | 171 |R|} |
172 | 172 |
173 function throwException() { | 173 function throwException() { |
174 #throw #new Error(); | 174 |_|throw |C|new Error(); |
175 #} | 175 |R|} |
176 | 176 |
177 function testCaughtException() { | 177 function testCaughtException() { |
178 try { | 178 try { |
179 #throwException() | 179 |C|throwException() |
180 } catch (e) { | 180 } catch (e) { |
181 #return; | 181 |_|return; |
182 } | 182 } |
183 #} | 183 |R|} |
184 | 184 |
185 function testClasses() { | 185 function testClasses() { |
186 #class Cat { | 186 |_|class Cat { |
187 constructor(name) { | 187 constructor(name) { |
188 #this.name = name; | 188 |_|this.name = name; |
189 #} | 189 |R|} |
190 | 190 |
191 speak() { | 191 speak() { |
192 #} | 192 |R|} |
193 } | 193 } |
194 #class Lion extends Cat { | 194 |_|class Lion extends Cat { |
195 constructor(name) { | 195 constructor(name) { |
196 #super(name); | 196 |C|super(name); |
197 #} | 197 |R|} |
198 | 198 |
199 speak() { | 199 speak() { |
200 #super.#speak(); | 200 |_|super.|C|speak(); |
201 #} | 201 |R|} |
202 } | 202 } |
203 #new Lion().#speak(); | 203 |C|new Lion().|C|speak(); |
204 #} | 204 |R|} |
205 | 205 |
206 async function asyncFoo() { | 206 async function asyncFoo() { |
207 #await Promise.resolve().then(v => v #* 2#); | 207 |_|await Promise.resolve().then(v => v |_|* 2|R|); |
208 #return42(); | 208 |C|return42(); |
209 #await #asyncBoo(); | 209 |_|await |C|asyncBoo(); |
210 #} | 210 |R|} |
211 | 211 |
212 async function asyncBoo() { | 212 async function asyncBoo() { |
213 #await Promise.resolve(); | 213 |_|await Promise.resolve(); |
214 #} | 214 |R|} |
215 | 215 |
216 async function testAsyncAwait() { | 216 async function testAsyncAwait() { |
217 #await asyncFoo(); | 217 |_|await asyncFoo(); |
218 #await #awaitBoo(); | 218 |_|await |C|awaitBoo(); |
219 #} | 219 |R|} |
220 | 220 |
221 // TODO(kozyatinskiy): fix this. | 221 // TODO(kozyatinskiy): fix this. |
222 async function testPromiseAsyncWithCode() { | 222 async function testPromiseAsyncWithCode() { |
223 var nextTest; | 223 var nextTest; |
224 var testPromise = #new Promise(resolve => nextTest #= resolve#); | 224 var testPromise = |C|new Promise(resolve => nextTest |_|= resolve|R|); |
225 async function main() { | 225 async function main() { |
226 async function foo() { | 226 async function foo() { |
227 var resolveNested; | 227 var resolveNested; |
228 var p = #new Promise(resolve => resolveNested #= resolve#); | 228 var p = |C|new Promise(resolve => resolveNested |_|= resolve|R|); |
229 #setTimeout(resolveNested, 0); | 229 |C|setTimeout(resolveNested, 0); |
230 #await #p; | 230 |_|await |_|p; |
231 #} | 231 |R|} |
232 #setTimeout(returnCall, 0); | 232 |C|setTimeout(returnCall, 0); |
233 #await #foo(); | 233 |_|await |C|foo(); |
234 #await #foo(); | 234 |_|await |C|foo(); |
235 #nextTest(); | 235 |C|nextTest(); |
236 #} | 236 |R|} |
237 #main(); | 237 |C|main(); |
238 #return testPromise; | 238 |_|return testPromise; |
239 #} | 239 |R|} |
240 | 240 |
241 function returnFunction() { | 241 function returnFunction() { |
242 #return returnObject; | 242 |_|return returnObject; |
243 #} | 243 |R|} |
244 | 244 |
245 async function testPromiseComplex() { | 245 async function testPromiseComplex() { |
246 var nextTest; | 246 var nextTest; |
247 var testPromise = #new Promise(resolve => nextTest #= resolve#); | 247 var testPromise = |C|new Promise(resolve => nextTest |_|= resolve|R|); |
248 async function main() { | 248 async function main() { |
249 async function foo() { | 249 async function foo() { |
250 #await Promise.resolve(); | 250 |_|await Promise.resolve(); |
251 #return 42; | 251 |_|return 42; |
252 #} | 252 |R|} |
253 var x = #1; | 253 var x = |_|1; |
254 var y = #2; | 254 var y = |_|2; |
255 #returnFunction(#emptyFunction(), x++, --y, x => 2 #* x#, #returnCall())#().
a = #await #foo((a => 2 #*a#)#(5)); | 255 |C|returnFunction(|C|emptyFunction(), x++, --y, x => 2 |_|* x|R|, |C|returnC
all())|C|().a = |_|await |C|foo((a => 2 |_|*a|R|)|C|(5)); |
256 #nextTest(); | 256 |C|nextTest(); |
257 #} | 257 |R|} |
258 #main(); | 258 |C|main(); |
259 #return testPromise; | 259 |_|return testPromise; |
260 #} | 260 |R|} |
261 | 261 |
262 function twiceDefined() { | 262 function twiceDefined() { |
263 return a + b; | 263 return a + b; |
264 } | 264 } |
265 | 265 |
266 function twiceDefined() { | 266 function twiceDefined() { |
267 #return a + b; | 267 |_|return a + b; |
268 #} | 268 |R|} |
269 | 269 |
270 | 270 |
OLD | NEW |