OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 336 } |
337 } | 337 } |
338 CHECK_TYPES_END | 338 CHECK_TYPES_END |
339 } | 339 } |
340 | 340 |
341 | 341 |
342 TEST(VisitThrow) { | 342 TEST(VisitThrow) { |
343 v8::V8::Initialize(); | 343 v8::V8::Initialize(); |
344 HandleAndZoneScope handles; | 344 HandleAndZoneScope handles; |
345 ZoneVector<ExpressionTypeEntry> types(handles.main_zone()); | 345 ZoneVector<ExpressionTypeEntry> types(handles.main_zone()); |
346 // Check that traversing an empty for statement works. | |
347 const char test_function[] = | 346 const char test_function[] = |
348 "function foo() {\n" | 347 "function foo() {\n" |
349 " throw 123;\n" | 348 " throw 123;\n" |
350 "}\n"; | 349 "}\n"; |
351 CollectTypes(&handles, test_function, &types); | 350 CollectTypes(&handles, test_function, &types); |
352 CHECK_TYPES_BEGIN { | 351 CHECK_TYPES_BEGIN { |
353 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { | 352 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { |
354 CHECK_EXPR(Throw, Bounds::Unbounded()) { | 353 CHECK_EXPR(Throw, Bounds::Unbounded()) { |
355 CHECK_EXPR(Literal, Bounds::Unbounded()); | 354 CHECK_EXPR(Literal, Bounds::Unbounded()); |
356 } | 355 } |
357 } | 356 } |
358 } | 357 } |
359 CHECK_TYPES_END | 358 CHECK_TYPES_END |
360 } | 359 } |
361 | 360 |
362 | 361 |
363 TEST(VisitYield) { | 362 TEST(VisitYield) { |
364 v8::V8::Initialize(); | 363 v8::V8::Initialize(); |
365 HandleAndZoneScope handles; | 364 HandleAndZoneScope handles; |
366 ZoneVector<ExpressionTypeEntry> types(handles.main_zone()); | 365 ZoneVector<ExpressionTypeEntry> types(handles.main_zone()); |
367 // Check that traversing an empty for statement works. | |
368 const char test_function[] = | 366 const char test_function[] = |
369 "function* foo() {\n" | 367 "function* foo() {\n" |
370 " yield 123;\n" | 368 " yield 123;\n" |
371 "}\n"; | 369 "}\n"; |
372 CollectTypes(&handles, test_function, &types); | 370 CollectTypes(&handles, test_function, &types); |
373 CHECK_TYPES_BEGIN { | 371 CHECK_TYPES_BEGIN { |
374 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { | 372 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { |
375 // Generator function yields generator on entry. | 373 // Implicit initial yield |
376 CHECK_EXPR(Yield, Bounds::Unbounded()) { | 374 CHECK_EXPR(Yield, Bounds::Unbounded()) { |
377 CHECK_VAR(.generator_object, Bounds::Unbounded()); | 375 CHECK_VAR(.generator_object, Bounds::Unbounded()); |
378 CHECK_EXPR(Assignment, Bounds::Unbounded()) { | 376 CHECK_EXPR(Assignment, Bounds::Unbounded()) { |
379 CHECK_VAR(.generator_object, Bounds::Unbounded()); | 377 CHECK_VAR(.generator_object, Bounds::Unbounded()); |
380 CHECK_EXPR(CallRuntime, Bounds::Unbounded()); | 378 CHECK_EXPR(CallRuntime, Bounds::Unbounded()); |
381 } | 379 } |
382 } | 380 } |
383 // Then yields undefined. | 381 // Explicit yield |
384 CHECK_EXPR(Yield, Bounds::Unbounded()) { | 382 CHECK_EXPR(Yield, Bounds::Unbounded()) { |
385 CHECK_VAR(.generator_object, Bounds::Unbounded()); | 383 CHECK_VAR(.generator_object, Bounds::Unbounded()); |
386 CHECK_EXPR(Literal, Bounds::Unbounded()); | 384 CHECK_EXPR(Literal, Bounds::Unbounded()); |
387 } | 385 } |
388 // Then yields 123. | 386 // Implicit final yield |
389 CHECK_EXPR(Yield, Bounds::Unbounded()) { | 387 CHECK_EXPR(Yield, Bounds::Unbounded()) { |
390 CHECK_VAR(.generator_object, Bounds::Unbounded()); | 388 CHECK_VAR(.generator_object, Bounds::Unbounded()); |
391 CHECK_EXPR(Literal, Bounds::Unbounded()); | 389 CHECK_EXPR(Literal, Bounds::Unbounded()); |
392 } | 390 } |
| 391 // Implicit finally clause |
| 392 CHECK_EXPR(CallRuntime, Bounds::Unbounded()) { |
| 393 CHECK_VAR(.generator_object, Bounds::Unbounded()); |
| 394 } |
393 } | 395 } |
394 } | 396 } |
395 CHECK_TYPES_END | 397 CHECK_TYPES_END |
396 } | 398 } |
397 | 399 |
398 | 400 |
399 TEST(VisitSkipping) { | 401 TEST(VisitSkipping) { |
400 v8::V8::Initialize(); | 402 v8::V8::Initialize(); |
401 HandleAndZoneScope handles; | 403 HandleAndZoneScope handles; |
402 ZoneVector<ExpressionTypeEntry> types(handles.main_zone()); | 404 ZoneVector<ExpressionTypeEntry> types(handles.main_zone()); |
403 // Check that traversing an empty for statement works. | |
404 const char test_function[] = | 405 const char test_function[] = |
405 "function foo(x) {\n" | 406 "function foo(x) {\n" |
406 " return (x + x) + 1;\n" | 407 " return (x + x) + 1;\n" |
407 "}\n"; | 408 "}\n"; |
408 CollectTypes(&handles, test_function, &types); | 409 CollectTypes(&handles, test_function, &types); |
409 CHECK_TYPES_BEGIN { | 410 CHECK_TYPES_BEGIN { |
410 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { | 411 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { |
411 CHECK_EXPR(BinaryOperation, Bounds::Unbounded()) { | 412 CHECK_EXPR(BinaryOperation, Bounds::Unbounded()) { |
412 // Skip x + x | 413 // Skip x + x |
413 CHECK_SKIP(); | 414 CHECK_SKIP(); |
414 CHECK_EXPR(Literal, Bounds::Unbounded()); | 415 CHECK_EXPR(Literal, Bounds::Unbounded()); |
415 } | 416 } |
416 } | 417 } |
417 } | 418 } |
418 CHECK_TYPES_END | 419 CHECK_TYPES_END |
419 } | 420 } |
OLD | NEW |