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.Block, | 205 CheckScopeChain([debug.ScopeType.Local, |
206 debug.ScopeType.Local, | |
207 debug.ScopeType.Global], exec_state); | 206 debug.ScopeType.Global], exec_state); |
208 CheckScopeContent({}, 0, exec_state); | 207 CheckScopeContent({}, 0, exec_state); |
209 CheckScopeContent({}, 1, exec_state); | |
210 }; | 208 }; |
211 local_block_1(); | 209 local_block_1(); |
212 EndTest(); | 210 EndTest(); |
213 | 211 |
214 | 212 |
215 // Local scope with a parameter. | 213 // Simple empty block scope in local scope with a parameter. |
216 BeginTest("Local 2"); | 214 BeginTest("Local 2"); |
217 | 215 |
218 function local_2(a) { | 216 function local_2(a) { |
219 { | 217 { |
220 debugger; | 218 debugger; |
221 } | 219 } |
222 } | 220 } |
223 | 221 |
224 listener_delegate = function(exec_state) { | 222 listener_delegate = function(exec_state) { |
225 CheckScopeChain([debug.ScopeType.Block, | 223 CheckScopeChain([debug.ScopeType.Local, |
226 debug.ScopeType.Local, | |
227 debug.ScopeType.Global], exec_state); | 224 debug.ScopeType.Global], exec_state); |
228 CheckScopeContent({a:1}, 1, exec_state); | 225 CheckScopeContent({a:1}, 0, exec_state); |
229 }; | 226 }; |
230 local_2(1); | 227 local_2(1); |
231 EndTest(); | 228 EndTest(); |
232 | 229 |
233 | 230 |
234 // Local scope with a parameter and a local variable. | 231 // Local scope with a parameter and a local variable. |
235 BeginTest("Local 3"); | 232 BeginTest("Local 3"); |
236 | 233 |
237 function local_3(a) { | 234 function local_3(a) { |
238 let x = 3; | 235 let x = 3; |
(...skipping 20 matching lines...) Expand all Loading... | |
259 | 256 |
260 listener_delegate = function(exec_state) { | 257 listener_delegate = function(exec_state) { |
261 CheckScopeChain([debug.ScopeType.Local, | 258 CheckScopeChain([debug.ScopeType.Local, |
262 debug.ScopeType.Global], exec_state); | 259 debug.ScopeType.Global], exec_state); |
263 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); | 260 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); |
264 }; | 261 }; |
265 local_4(1, 2); | 262 local_4(1, 2); |
266 EndTest(); | 263 EndTest(); |
267 | 264 |
268 | 265 |
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. | |
Jakob Kummerow
2011/09/01 15:40:10
Forgot to edit the comment?
Steven
2011/09/02 12:43:43
Indeed.
On 2011/09/01 15:40:10, Jakob wrote:
| |
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 | |
269 // Single empty with block. | 332 // Single empty with block. |
270 BeginTest("With block 1"); | 333 BeginTest("With block 1"); |
271 | 334 |
272 function with_block_1() { | 335 function with_block_1() { |
273 with({}) { | 336 with({}) { |
274 debugger; | 337 debugger; |
275 } | 338 } |
276 } | 339 } |
277 | 340 |
278 listener_delegate = function(exec_state) { | 341 listener_delegate = function(exec_state) { |
279 CheckScopeChain([debug.ScopeType.Block, | 342 CheckScopeChain([debug.ScopeType.With, |
280 debug.ScopeType.With, | |
281 debug.ScopeType.Local, | 343 debug.ScopeType.Local, |
282 debug.ScopeType.Global], exec_state); | 344 debug.ScopeType.Global], exec_state); |
283 CheckScopeContent({}, 0, exec_state); | 345 CheckScopeContent({}, 0, exec_state); |
284 CheckScopeContent({}, 1, exec_state); | 346 CheckScopeContent({}, 1, exec_state); |
285 }; | 347 }; |
286 with_block_1(); | 348 with_block_1(); |
287 EndTest(); | 349 EndTest(); |
288 | 350 |
289 | 351 |
290 // Nested empty with blocks. | 352 // Nested empty with blocks. |
291 BeginTest("With block 2"); | 353 BeginTest("With block 2"); |
292 | 354 |
293 function with_block_2() { | 355 function with_block_2() { |
294 with({}) { | 356 with({}) { |
295 with({}) { | 357 with({}) { |
296 debugger; | 358 debugger; |
297 } | 359 } |
298 } | 360 } |
299 } | 361 } |
300 | 362 |
301 listener_delegate = function(exec_state) { | 363 listener_delegate = function(exec_state) { |
302 CheckScopeChain([debug.ScopeType.Block, | 364 CheckScopeChain([debug.ScopeType.With, |
303 debug.ScopeType.With, | |
304 debug.ScopeType.Block, | |
305 debug.ScopeType.With, | 365 debug.ScopeType.With, |
306 debug.ScopeType.Local, | 366 debug.ScopeType.Local, |
307 debug.ScopeType.Global], exec_state); | 367 debug.ScopeType.Global], exec_state); |
308 CheckScopeContent({}, 0, exec_state); | 368 CheckScopeContent({}, 0, exec_state); |
309 CheckScopeContent({}, 1, exec_state); | 369 CheckScopeContent({}, 1, exec_state); |
310 CheckScopeContent({}, 2, exec_state); | 370 CheckScopeContent({}, 2, exec_state); |
311 CheckScopeContent({}, 3, exec_state); | |
312 }; | 371 }; |
313 with_block_2(); | 372 with_block_2(); |
314 EndTest(); | 373 EndTest(); |
315 | 374 |
316 | 375 |
317 // With block using an in-place object literal. | 376 // With block using an in-place object literal. |
318 BeginTest("With block 3"); | 377 BeginTest("With block 3"); |
319 | 378 |
320 function with_block_3() { | 379 function with_block_3() { |
321 with({a:1,b:2}) { | 380 with({a:1,b:2}) { |
322 debugger; | 381 debugger; |
323 } | 382 } |
324 } | 383 } |
325 | 384 |
326 listener_delegate = function(exec_state) { | 385 listener_delegate = function(exec_state) { |
327 CheckScopeChain([debug.ScopeType.Block, | 386 CheckScopeChain([debug.ScopeType.With, |
328 debug.ScopeType.With, | |
329 debug.ScopeType.Local, | 387 debug.ScopeType.Local, |
330 debug.ScopeType.Global], exec_state); | 388 debug.ScopeType.Global], exec_state); |
331 CheckScopeContent({}, 0, exec_state); | 389 CheckScopeContent({a:1,b:2}, 0, exec_state); |
332 CheckScopeContent({a:1,b:2}, 1, exec_state); | |
333 }; | 390 }; |
334 with_block_3(); | 391 with_block_3(); |
335 EndTest(); | 392 EndTest(); |
336 | 393 |
337 | 394 |
338 // Nested with blocks using in-place object literals. | 395 // Nested with blocks using in-place object literals. |
339 BeginTest("With block 4"); | 396 BeginTest("With block 4"); |
340 | 397 |
341 function with_block_4() { | 398 function with_block_4() { |
342 with({a:1,b:2}) { | 399 with({a:1,b:2}) { |
343 with({a:2,b:1}) { | 400 with({a:2,b:1}) { |
344 debugger; | 401 debugger; |
345 } | 402 } |
346 } | 403 } |
347 } | 404 } |
348 | 405 |
349 listener_delegate = function(exec_state) { | 406 listener_delegate = function(exec_state) { |
350 CheckScopeChain([debug.ScopeType.Block, | 407 CheckScopeChain([debug.ScopeType.With, |
351 debug.ScopeType.With, | |
352 debug.ScopeType.Block, | |
353 debug.ScopeType.With, | 408 debug.ScopeType.With, |
354 debug.ScopeType.Local, | 409 debug.ScopeType.Local, |
355 debug.ScopeType.Global], exec_state); | 410 debug.ScopeType.Global], exec_state); |
356 CheckScopeContent({a:2,b:1}, 1, exec_state); | 411 CheckScopeContent({a:2,b:1}, 0, exec_state); |
357 CheckScopeContent({a:1,b:2}, 3, exec_state); | 412 CheckScopeContent({a:1,b:2}, 1, exec_state); |
358 }; | 413 }; |
359 with_block_4(); | 414 with_block_4(); |
360 EndTest(); | 415 EndTest(); |
361 | 416 |
362 | 417 |
363 // Simple closure formed by returning an inner function referering to an outer | 418 // Simple closure formed by returning an inner function referering to an outer |
364 // block local variable and an outer function's parameter. | 419 // block local variable and an outer function's parameter. |
365 BeginTest("Closure 1"); | 420 BeginTest("Closure 1"); |
366 | 421 |
367 function closure_1(a) { | 422 function closure_1(a) { |
(...skipping 12 matching lines...) Expand all Loading... | |
380 listener_delegate = function(exec_state) { | 435 listener_delegate = function(exec_state) { |
381 CheckScopeChain([debug.ScopeType.Local, | 436 CheckScopeChain([debug.ScopeType.Local, |
382 debug.ScopeType.Block, | 437 debug.ScopeType.Block, |
383 debug.ScopeType.Closure, | 438 debug.ScopeType.Closure, |
384 debug.ScopeType.Global], exec_state); | 439 debug.ScopeType.Global], exec_state); |
385 CheckScopeContent({}, 0, exec_state); | 440 CheckScopeContent({}, 0, exec_state); |
386 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); | 441 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); |
387 }; | 442 }; |
388 closure_1(1)(); | 443 closure_1(1)(); |
389 EndTest(); | 444 EndTest(); |
OLD | NEW |