OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Simple empty block scope in local scope. | 195 // Simple empty block scope in local scope. |
196 BeginTest("Local block 1"); | 196 BeginTest("Local block 1"); |
197 | 197 |
198 function local_block_1() { | 198 function local_block_1() { |
199 { | 199 { |
200 debugger; | 200 debugger; |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 listener_delegate = function(exec_state) { | 204 listener_delegate = function(exec_state) { |
205 CheckScopeChain([debug.ScopeType.Local, | 205 CheckScopeChain([debug.ScopeType.Block, |
| 206 debug.ScopeType.Local, |
206 debug.ScopeType.Global], exec_state); | 207 debug.ScopeType.Global], exec_state); |
207 CheckScopeContent({}, 0, exec_state); | 208 CheckScopeContent({}, 0, exec_state); |
| 209 CheckScopeContent({}, 1, exec_state); |
208 }; | 210 }; |
209 local_block_1(); | 211 local_block_1(); |
210 EndTest(); | 212 EndTest(); |
211 | 213 |
212 | 214 |
213 // Simple empty block scope in local scope with a parameter. | 215 // Local scope with a parameter. |
214 BeginTest("Local 2"); | 216 BeginTest("Local 2"); |
215 | 217 |
216 function local_2(a) { | 218 function local_2(a) { |
217 { | 219 { |
218 debugger; | 220 debugger; |
219 } | 221 } |
220 } | 222 } |
221 | 223 |
222 listener_delegate = function(exec_state) { | 224 listener_delegate = function(exec_state) { |
223 CheckScopeChain([debug.ScopeType.Local, | 225 CheckScopeChain([debug.ScopeType.Block, |
| 226 debug.ScopeType.Local, |
224 debug.ScopeType.Global], exec_state); | 227 debug.ScopeType.Global], exec_state); |
225 CheckScopeContent({a:1}, 0, exec_state); | 228 CheckScopeContent({a:1}, 1, exec_state); |
226 }; | 229 }; |
227 local_2(1); | 230 local_2(1); |
228 EndTest(); | 231 EndTest(); |
229 | 232 |
230 | 233 |
231 // Local scope with a parameter and a local variable. | 234 // Local scope with a parameter and a local variable. |
232 BeginTest("Local 3"); | 235 BeginTest("Local 3"); |
233 | 236 |
234 function local_3(a) { | 237 function local_3(a) { |
235 let x = 3; | 238 let x = 3; |
(...skipping 20 matching lines...) Expand all Loading... |
256 | 259 |
257 listener_delegate = function(exec_state) { | 260 listener_delegate = function(exec_state) { |
258 CheckScopeChain([debug.ScopeType.Local, | 261 CheckScopeChain([debug.ScopeType.Local, |
259 debug.ScopeType.Global], exec_state); | 262 debug.ScopeType.Global], exec_state); |
260 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); | 263 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); |
261 }; | 264 }; |
262 local_4(1, 2); | 265 local_4(1, 2); |
263 EndTest(); | 266 EndTest(); |
264 | 267 |
265 | 268 |
266 // Single variable in a block scope. | |
267 BeginTest("Local 5"); | |
268 | |
269 function local_5(a) { | |
270 { | |
271 let x = 5; | |
272 debugger; | |
273 } | |
274 } | |
275 | |
276 listener_delegate = function(exec_state) { | |
277 CheckScopeChain([debug.ScopeType.Block, | |
278 debug.ScopeType.Local, | |
279 debug.ScopeType.Global], exec_state); | |
280 CheckScopeContent({x:5}, 0, exec_state); | |
281 CheckScopeContent({a:1}, 1, exec_state); | |
282 }; | |
283 local_5(1); | |
284 EndTest(); | |
285 | |
286 | |
287 // Two variables in a block scope. | |
288 BeginTest("Local 6"); | |
289 | |
290 function local_6(a) { | |
291 { | |
292 let x = 6; | |
293 let y = 7; | |
294 debugger; | |
295 } | |
296 } | |
297 | |
298 listener_delegate = function(exec_state) { | |
299 CheckScopeChain([debug.ScopeType.Block, | |
300 debug.ScopeType.Local, | |
301 debug.ScopeType.Global], exec_state); | |
302 CheckScopeContent({x:6,y:7}, 0, exec_state); | |
303 CheckScopeContent({a:1}, 1, exec_state); | |
304 }; | |
305 local_6(1); | |
306 EndTest(); | |
307 | |
308 | |
309 // Two variables in a block scope. | |
310 BeginTest("Local 7"); | |
311 | |
312 function local_7(a) { | |
313 { | |
314 { | |
315 let x = 8; | |
316 debugger; | |
317 } | |
318 } | |
319 } | |
320 | |
321 listener_delegate = function(exec_state) { | |
322 CheckScopeChain([debug.ScopeType.Block, | |
323 debug.ScopeType.Local, | |
324 debug.ScopeType.Global], exec_state); | |
325 CheckScopeContent({x:8}, 0, exec_state); | |
326 CheckScopeContent({a:1}, 1, exec_state); | |
327 }; | |
328 local_7(1); | |
329 EndTest(); | |
330 | |
331 | |
332 // Single empty with block. | 269 // Single empty with block. |
333 BeginTest("With block 1"); | 270 BeginTest("With block 1"); |
334 | 271 |
335 function with_block_1() { | 272 function with_block_1() { |
336 with({}) { | 273 with({}) { |
337 debugger; | 274 debugger; |
338 } | 275 } |
339 } | 276 } |
340 | 277 |
341 listener_delegate = function(exec_state) { | 278 listener_delegate = function(exec_state) { |
342 CheckScopeChain([debug.ScopeType.With, | 279 CheckScopeChain([debug.ScopeType.Block, |
| 280 debug.ScopeType.With, |
343 debug.ScopeType.Local, | 281 debug.ScopeType.Local, |
344 debug.ScopeType.Global], exec_state); | 282 debug.ScopeType.Global], exec_state); |
345 CheckScopeContent({}, 0, exec_state); | 283 CheckScopeContent({}, 0, exec_state); |
346 CheckScopeContent({}, 1, exec_state); | 284 CheckScopeContent({}, 1, exec_state); |
347 }; | 285 }; |
348 with_block_1(); | 286 with_block_1(); |
349 EndTest(); | 287 EndTest(); |
350 | 288 |
351 | 289 |
352 // Nested empty with blocks. | 290 // Nested empty with blocks. |
353 BeginTest("With block 2"); | 291 BeginTest("With block 2"); |
354 | 292 |
355 function with_block_2() { | 293 function with_block_2() { |
356 with({}) { | 294 with({}) { |
357 with({}) { | 295 with({}) { |
358 debugger; | 296 debugger; |
359 } | 297 } |
360 } | 298 } |
361 } | 299 } |
362 | 300 |
363 listener_delegate = function(exec_state) { | 301 listener_delegate = function(exec_state) { |
364 CheckScopeChain([debug.ScopeType.With, | 302 CheckScopeChain([debug.ScopeType.Block, |
| 303 debug.ScopeType.With, |
| 304 debug.ScopeType.Block, |
365 debug.ScopeType.With, | 305 debug.ScopeType.With, |
366 debug.ScopeType.Local, | 306 debug.ScopeType.Local, |
367 debug.ScopeType.Global], exec_state); | 307 debug.ScopeType.Global], exec_state); |
368 CheckScopeContent({}, 0, exec_state); | 308 CheckScopeContent({}, 0, exec_state); |
369 CheckScopeContent({}, 1, exec_state); | 309 CheckScopeContent({}, 1, exec_state); |
370 CheckScopeContent({}, 2, exec_state); | 310 CheckScopeContent({}, 2, exec_state); |
| 311 CheckScopeContent({}, 3, exec_state); |
371 }; | 312 }; |
372 with_block_2(); | 313 with_block_2(); |
373 EndTest(); | 314 EndTest(); |
374 | 315 |
375 | 316 |
376 // With block using an in-place object literal. | 317 // With block using an in-place object literal. |
377 BeginTest("With block 3"); | 318 BeginTest("With block 3"); |
378 | 319 |
379 function with_block_3() { | 320 function with_block_3() { |
380 with({a:1,b:2}) { | 321 with({a:1,b:2}) { |
381 debugger; | 322 debugger; |
382 } | 323 } |
383 } | 324 } |
384 | 325 |
385 listener_delegate = function(exec_state) { | 326 listener_delegate = function(exec_state) { |
386 CheckScopeChain([debug.ScopeType.With, | 327 CheckScopeChain([debug.ScopeType.Block, |
| 328 debug.ScopeType.With, |
387 debug.ScopeType.Local, | 329 debug.ScopeType.Local, |
388 debug.ScopeType.Global], exec_state); | 330 debug.ScopeType.Global], exec_state); |
389 CheckScopeContent({a:1,b:2}, 0, exec_state); | 331 CheckScopeContent({}, 0, exec_state); |
| 332 CheckScopeContent({a:1,b:2}, 1, exec_state); |
390 }; | 333 }; |
391 with_block_3(); | 334 with_block_3(); |
392 EndTest(); | 335 EndTest(); |
393 | 336 |
394 | 337 |
395 // Nested with blocks using in-place object literals. | 338 // Nested with blocks using in-place object literals. |
396 BeginTest("With block 4"); | 339 BeginTest("With block 4"); |
397 | 340 |
398 function with_block_4() { | 341 function with_block_4() { |
399 with({a:1,b:2}) { | 342 with({a:1,b:2}) { |
400 with({a:2,b:1}) { | 343 with({a:2,b:1}) { |
401 debugger; | 344 debugger; |
402 } | 345 } |
403 } | 346 } |
404 } | 347 } |
405 | 348 |
406 listener_delegate = function(exec_state) { | 349 listener_delegate = function(exec_state) { |
407 CheckScopeChain([debug.ScopeType.With, | 350 CheckScopeChain([debug.ScopeType.Block, |
| 351 debug.ScopeType.With, |
| 352 debug.ScopeType.Block, |
408 debug.ScopeType.With, | 353 debug.ScopeType.With, |
409 debug.ScopeType.Local, | 354 debug.ScopeType.Local, |
410 debug.ScopeType.Global], exec_state); | 355 debug.ScopeType.Global], exec_state); |
411 CheckScopeContent({a:2,b:1}, 0, exec_state); | 356 CheckScopeContent({a:2,b:1}, 1, exec_state); |
412 CheckScopeContent({a:1,b:2}, 1, exec_state); | 357 CheckScopeContent({a:1,b:2}, 3, exec_state); |
413 }; | 358 }; |
414 with_block_4(); | 359 with_block_4(); |
415 EndTest(); | 360 EndTest(); |
416 | 361 |
417 | 362 |
418 // Simple closure formed by returning an inner function referering to an outer | 363 // Simple closure formed by returning an inner function referering to an outer |
419 // block local variable and an outer function's parameter. | 364 // block local variable and an outer function's parameter. |
420 BeginTest("Closure 1"); | 365 BeginTest("Closure 1"); |
421 | 366 |
422 function closure_1(a) { | 367 function closure_1(a) { |
(...skipping 12 matching lines...) Expand all Loading... |
435 listener_delegate = function(exec_state) { | 380 listener_delegate = function(exec_state) { |
436 CheckScopeChain([debug.ScopeType.Local, | 381 CheckScopeChain([debug.ScopeType.Local, |
437 debug.ScopeType.Block, | 382 debug.ScopeType.Block, |
438 debug.ScopeType.Closure, | 383 debug.ScopeType.Closure, |
439 debug.ScopeType.Global], exec_state); | 384 debug.ScopeType.Global], exec_state); |
440 CheckScopeContent({}, 0, exec_state); | 385 CheckScopeContent({}, 0, exec_state); |
441 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); | 386 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); |
442 }; | 387 }; |
443 closure_1(1)(); | 388 closure_1(1)(); |
444 EndTest(); | 389 EndTest(); |
OLD | NEW |