OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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: --ignition | 5 // Flags: --ignition |
6 // The functions used for testing backtraces. They are at the top to make the | 6 // The functions used for testing backtraces. They are at the top to make the |
7 // testing of source line/column easier. | 7 // testing of source line/column easier. |
8 | 8 |
9 var Debug = debug.Debug; | 9 var Debug = debug.Debug; |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 // Simple empty closure scope. | 102 // Simple empty closure scope. |
103 | 103 |
104 function *gen1() { | 104 function *gen1() { |
105 yield 1; | 105 yield 1; |
106 return 2; | 106 return 2; |
107 } | 107 } |
108 | 108 |
109 var g = gen1(); | 109 var g = gen1(); |
110 CheckScopeChain([debug.ScopeType.Closure, | 110 CheckScopeChain([debug.ScopeType.Script, |
111 debug.ScopeType.Script, | |
112 debug.ScopeType.Global], g); | 111 debug.ScopeType.Global], g); |
113 CheckScopeContent({}, 0, g); | |
114 | 112 |
115 // Closure scope with a parameter. | 113 // Closure scope with a parameter. |
116 | 114 |
117 function *gen2(a) { | 115 function *gen2(a) { |
118 yield a; | 116 yield a; |
119 return 2; | 117 return 2; |
120 } | 118 } |
121 | 119 |
122 g = gen2(42); | 120 g = gen2(42); |
123 CheckScopeChain([debug.ScopeType.Closure, | 121 CheckScopeChain([debug.ScopeType.Closure, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 with({}) { | 181 with({}) { |
184 yield 1; | 182 yield 1; |
185 } | 183 } |
186 yield 2; | 184 yield 2; |
187 return 3; | 185 return 3; |
188 } | 186 } |
189 | 187 |
190 g = gen6(); | 188 g = gen6(); |
191 g.next(); | 189 g.next(); |
192 CheckScopeChain([debug.ScopeType.With, | 190 CheckScopeChain([debug.ScopeType.With, |
193 debug.ScopeType.Closure, | |
194 debug.ScopeType.Script, | |
195 debug.ScopeType.Global], g); | |
196 CheckScopeContent({}, 0, g); | |
197 | |
198 g.next(); | |
199 CheckScopeChain([debug.ScopeType.Closure, | |
200 debug.ScopeType.Script, | 191 debug.ScopeType.Script, |
201 debug.ScopeType.Global], g); | 192 debug.ScopeType.Global], g); |
202 | 193 |
| 194 g.next(); |
| 195 CheckScopeChain([debug.ScopeType.Script, |
| 196 debug.ScopeType.Global], g); |
| 197 |
203 // Nested empty with blocks. | 198 // Nested empty with blocks. |
204 | 199 |
205 function *gen7() { | 200 function *gen7() { |
206 with({}) { | 201 with({}) { |
207 with({}) { | 202 with({}) { |
208 yield 1; | 203 yield 1; |
209 } | 204 } |
210 yield 2; | 205 yield 2; |
211 } | 206 } |
212 return 3; | 207 return 3; |
213 } | 208 } |
214 | 209 |
215 g = gen7(); | 210 g = gen7(); |
216 g.next(); | 211 g.next(); |
217 CheckScopeChain([debug.ScopeType.With, | 212 CheckScopeChain([debug.ScopeType.With, |
218 debug.ScopeType.With, | 213 debug.ScopeType.With, |
219 debug.ScopeType.Closure, | |
220 debug.ScopeType.Script, | 214 debug.ScopeType.Script, |
221 debug.ScopeType.Global], g); | 215 debug.ScopeType.Global], g); |
222 CheckScopeContent({}, 0, g); | 216 CheckScopeContent({}, 0, g); |
223 | 217 |
224 // Nested with blocks using in-place object literals. | 218 // Nested with blocks using in-place object literals. |
225 | 219 |
226 function *gen8() { | 220 function *gen8() { |
227 with({a: 1,b: 2}) { | 221 with({a: 1,b: 2}) { |
228 with({a: 2,b: 1}) { | 222 with({a: 2,b: 1}) { |
229 yield a; | 223 yield a; |
230 } | 224 } |
231 yield a; | 225 yield a; |
232 } | 226 } |
233 return 3; | 227 return 3; |
234 } | 228 } |
235 | 229 |
236 g = gen8(); | 230 g = gen8(); |
237 g.next(); | 231 g.next(); |
238 CheckScopeChain([debug.ScopeType.With, | 232 CheckScopeChain([debug.ScopeType.With, |
239 debug.ScopeType.With, | 233 debug.ScopeType.With, |
240 debug.ScopeType.Closure, | |
241 debug.ScopeType.Script, | 234 debug.ScopeType.Script, |
242 debug.ScopeType.Global], g); | 235 debug.ScopeType.Global], g); |
243 CheckScopeContent({a: 2, b: 1}, 0, g); | 236 CheckScopeContent({a: 2, b: 1}, 0, g); |
244 | 237 |
245 g.next(); | 238 g.next(); |
246 CheckScopeContent({a: 1, b: 2}, 0, g); | 239 CheckScopeContent({a: 1, b: 2}, 0, g); |
247 | 240 |
248 // Catch block. | 241 // Catch block. |
249 | 242 |
250 function *gen9() { | 243 function *gen9() { |
251 try { | 244 try { |
252 throw 42; | 245 throw 42; |
253 } catch (e) { | 246 } catch (e) { |
254 yield e; | 247 yield e; |
255 } | 248 } |
256 return 3; | 249 return 3; |
257 } | 250 } |
258 | 251 |
259 g = gen9(); | 252 g = gen9(); |
260 g.next(); | 253 g.next(); |
261 CheckScopeChain([debug.ScopeType.Catch, | 254 CheckScopeChain([debug.ScopeType.Catch, |
262 debug.ScopeType.Closure, | |
263 debug.ScopeType.Script, | 255 debug.ScopeType.Script, |
264 debug.ScopeType.Global], g); | 256 debug.ScopeType.Global], g); |
265 CheckScopeContent({e: 42}, 0, g); | 257 CheckScopeContent({e: 42}, 0, g); |
266 | 258 |
267 // For statement with block scope. | 259 // For statement with block scope. |
268 | 260 |
269 function *gen10() { | 261 function *gen10() { |
270 for (let i = 0; i < 42; i++) yield i; | 262 for (let i = 0; i < 42; i++) yield i; |
271 return 3; | 263 return 3; |
272 } | 264 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 302 |
311 // Set a variable in an empty scope. | 303 // Set a variable in an empty scope. |
312 | 304 |
313 function *gen13() { | 305 function *gen13() { |
314 yield 1; | 306 yield 1; |
315 return 2; | 307 return 2; |
316 } | 308 } |
317 | 309 |
318 var g = gen13(); | 310 var g = gen13(); |
319 assertThrows(() => Debug.generatorScope(g, 0).setVariableValue("a", 42)); | 311 assertThrows(() => Debug.generatorScope(g, 0).setVariableValue("a", 42)); |
320 CheckScopeContent({}, 0, g); | |
321 | 312 |
322 // Set a variable in a simple scope. | 313 // Set a variable in a simple scope. |
323 | 314 |
324 function *gen14() { | 315 function *gen14() { |
325 var a = 0; | 316 var a = 0; |
326 yield 1; | 317 yield 1; |
327 yield a; | 318 yield a; |
328 return 2; | 319 return 2; |
329 } | 320 } |
330 | 321 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 yield e; | 418 yield e; |
428 yield e; | 419 yield e; |
429 } | 420 } |
430 return 3; | 421 return 3; |
431 } | 422 } |
432 | 423 |
433 g = gen17(); | 424 g = gen17(); |
434 g.next(); | 425 g.next(); |
435 | 426 |
436 CheckScopeChain([debug.ScopeType.Catch, | 427 CheckScopeChain([debug.ScopeType.Catch, |
437 debug.ScopeType.Closure, | |
438 debug.ScopeType.Script, | 428 debug.ScopeType.Script, |
439 debug.ScopeType.Global], g); | 429 debug.ScopeType.Global], g); |
440 CheckScopeContent({e: 42}, 0, g); | 430 CheckScopeContent({e: 42}, 0, g); |
441 CheckScopeContent({xxxyyxxyx: 42284, | 431 CheckScopeContent({xxxyyxxyx: 42284, |
442 printProtocolMessages : printProtocolMessages, | 432 printProtocolMessages : printProtocolMessages, |
443 activeWrapper : activeWrapper, | 433 activeWrapper : activeWrapper, |
444 DebugWrapper : DebugWrapper | 434 DebugWrapper : DebugWrapper |
445 }, 2, g); | 435 }, 1, g); |
446 | 436 |
447 Debug.generatorScope(g, 0).setVariableValue("e", 1); | 437 Debug.generatorScope(g, 0).setVariableValue("e", 1); |
448 CheckScopeContent({e: 1}, 0, g); | 438 CheckScopeContent({e: 1}, 0, g); |
449 | 439 |
450 assertEquals(1, g.next().value); | 440 assertEquals(1, g.next().value); |
451 | 441 |
452 // Script scope. | 442 // Script scope. |
453 Debug.generatorScope(g, 2).setVariableValue("xxxyyxxyx", 42); | 443 Debug.generatorScope(g, 1).setVariableValue("xxxyyxxyx", 42); |
454 assertEquals(42, xxxyyxxyx); | 444 assertEquals(42, xxxyyxxyx); |
455 | 445 |
456 // Global scope. | 446 // Global scope. |
457 assertThrows(() => Debug.generatorScope(g, 3).setVariableValue("yyzyzzyz", 42)); | 447 assertThrows(() => Debug.generatorScope(g, 2).setVariableValue("yyzyzzyz", 42)); |
458 assertEquals(4829, yyzyzzyz); | 448 assertEquals(4829, yyzyzzyz); |
OLD | NEW |