Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: runtime/vm/flow_graph_builder_test.cc

Issue 1575953005: Source position tests for switch and try catch finally (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/compiler.h" 5 #include "vm/compiler.h"
6 #include "vm/dart_api_impl.h" 6 #include "vm/dart_api_impl.h"
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 spt.InstanceCallAt(4, 9, Token::kEQ); 558 spt.InstanceCallAt(4, 9, Token::kEQ);
559 spt.FuzzyInstructionMatchAt("Branch if StrictCompare", 4, 9); 559 spt.FuzzyInstructionMatchAt("Branch if StrictCompare", 4, 9);
560 spt.FuzzyInstructionMatchAt("LoadStaticField", 5, 12); 560 spt.FuzzyInstructionMatchAt("LoadStaticField", 5, 12);
561 spt.FuzzyInstructionMatchAt("DebugStepCheck", 5, 5); 561 spt.FuzzyInstructionMatchAt("DebugStepCheck", 5, 5);
562 spt.FuzzyInstructionMatchAt("Return", 5, 5); 562 spt.FuzzyInstructionMatchAt("Return", 5, 5);
563 spt.FuzzyInstructionMatchAt("LoadStaticField", 7, 12); 563 spt.FuzzyInstructionMatchAt("LoadStaticField", 7, 12);
564 spt.FuzzyInstructionMatchAt("DebugStepCheck", 7, 5); 564 spt.FuzzyInstructionMatchAt("DebugStepCheck", 7, 5);
565 spt.FuzzyInstructionMatchAt("Return", 7, 5); 565 spt.FuzzyInstructionMatchAt("Return", 7, 5);
566 } 566 }
567 567
568
569 TEST_CASE(SourcePosition_Switch) {
570 const char* kScript =
571 "var x = 5;\n"
572 "var y = 5;\n"
573 "main() {\n"
574 " switch (x) {\n"
575 " case 1: return 3;\n"
576 " case 2: return 4;\n"
577 " default: return 5;\n"
578 " }\n"
579 "}\n";
580
581
582 SourcePositionTest spt(thread, kScript);
583 spt.BuildGraphFor("main");
584
585 spt.FuzzyInstructionMatchAt("DebugStepCheck", 3, 5);
586 spt.FuzzyInstructionMatchAt("CheckStackOverflow", 3, 5);
587 spt.FuzzyInstructionMatchAt("Constant(#Field", 4, 11);
588 spt.FuzzyInstructionMatchAt("LoadStaticField", 4, 11);
589 spt.FuzzyInstructionMatchAt("StoreLocal(:switch_expr", 4, 11);
590
591 spt.FuzzyInstructionMatchAt("Constant(#1", 5, 10);
592 spt.FuzzyInstructionMatchAt("LoadLocal(:switch_expr", 5, 5); // 'c'
593 spt.InstanceCallAt(5, 10, Token::kEQ); // '1'
594
595 spt.FuzzyInstructionMatchAt("Constant(#3", 5, 20); // '3'
596 spt.FuzzyInstructionMatchAt("DebugStepCheck", 5, 13);
597 spt.FuzzyInstructionMatchAt("Return", 5, 13);
598
599 spt.FuzzyInstructionMatchAt("Constant(#2", 6, 10);
600 spt.FuzzyInstructionMatchAt("LoadLocal(:switch_expr", 6, 5); // 'c'
601 spt.InstanceCallAt(6, 10, Token::kEQ); // '1'
rmacnak 2016/01/12 22:59:21 '1' => '2'
Cutch 2016/01/12 23:02:15 Done.
602
603 spt.FuzzyInstructionMatchAt("Constant(#4", 6, 20); // '4'
604 spt.FuzzyInstructionMatchAt("DebugStepCheck", 6, 13);
605 spt.FuzzyInstructionMatchAt("Return", 6, 13);
606
607 spt.FuzzyInstructionMatchAt("Constant(#5", 7, 21); // '5'
608 spt.FuzzyInstructionMatchAt("DebugStepCheck", 7, 14);
609 spt.FuzzyInstructionMatchAt("Return", 7, 14);
610 }
611
612
613 TEST_CASE(SourcePosition_TryCatchFinally) {
614 const char* kScript =
615 "var x = 5;\n"
616 "var y = 5;\n"
617 "main() {\n"
618 " try {\n"
619 " throw 'A';\n"
620 " } catch (e) {\n"
621 " print(e);\n"
622 " return 77;\n"
623 " } finally {\n"
624 " return 99;\n"
625 " }\n"
626 "}\n";
627
628 SourcePositionTest spt(thread, kScript);
629 spt.BuildGraphFor("main");
630
631 spt.FuzzyInstructionMatchAt("DebugStepCheck", 3, 5);
632 spt.FuzzyInstructionMatchAt("CheckStackOverflow", 3, 5);
633
634 spt.FuzzyInstructionMatchAt("LoadLocal(:current_context", 4, 3); // 't'
635 spt.FuzzyInstructionMatchAt("StoreLocal(:saved_try_context", 4, 3);
636
637 spt.FuzzyInstructionMatchAt("Constant(#A", 5, 11); // 'A'
638 spt.FuzzyInstructionMatchAt("Throw", 5, 5); // 't'
639
640 spt.FuzzyInstructionMatchAt("LoadLocal(:saved_try_context", 6, 5); // 'c'
641 spt.FuzzyInstructionMatchAt("StoreLocal(:current_context", 6, 5); // 'c'
642 spt.FuzzyInstructionMatchAt("LoadLocal(:exception_var", 6, 5); // 'c'
643 spt.FuzzyInstructionMatchAt("StoreLocal(e", 6, 5); // 'c'
644
645 spt.FuzzyInstructionMatchAt("LoadLocal(e", 7, 11); // 'e'
646
647 spt.FuzzyInstructionMatchAt("StaticCall", 7, 5); // 'p'
648
649 spt.FuzzyInstructionMatchAt("Constant(#77", 8, 12); // '7'
650 spt.FuzzyInstructionMatchAt("StoreLocal(:finally_ret_val", 8, 5); // 'r'
651
652 spt.FuzzyInstructionMatchAt("Constant(#99", 10, 12); // '9'
653 spt.FuzzyInstructionMatchAt("Return", 10, 5); // 'r'
654
655 spt.FuzzyInstructionMatchAt("LoadLocal(:saved_try_context", 9, 13); // '{'
656 spt.FuzzyInstructionMatchAt("StoreLocal(:current_context", 9, 13); // '{'
657
658 spt.FuzzyInstructionMatchAt("Constant(#99", 10, 12); // '9'
659 spt.FuzzyInstructionMatchAt("Return", 10, 5); // 'r'
660 }
661
568 } // namespace dart 662 } // namespace dart
569 663
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698