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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder_test.cc
diff --git a/runtime/vm/flow_graph_builder_test.cc b/runtime/vm/flow_graph_builder_test.cc
index 4d747d6b960baebfcf98e6c6ac2f434ce5ee8743..c653737ab75441302979c379fb17a2dce9ad1fdd 100644
--- a/runtime/vm/flow_graph_builder_test.cc
+++ b/runtime/vm/flow_graph_builder_test.cc
@@ -565,5 +565,99 @@ TEST_CASE(SourcePosition_IfElse) {
spt.FuzzyInstructionMatchAt("Return", 7, 5);
}
+
+TEST_CASE(SourcePosition_Switch) {
+ const char* kScript =
+ "var x = 5;\n"
+ "var y = 5;\n"
+ "main() {\n"
+ " switch (x) {\n"
+ " case 1: return 3;\n"
+ " case 2: return 4;\n"
+ " default: return 5;\n"
+ " }\n"
+ "}\n";
+
+
+ SourcePositionTest spt(thread, kScript);
+ spt.BuildGraphFor("main");
+
+ spt.FuzzyInstructionMatchAt("DebugStepCheck", 3, 5);
+ spt.FuzzyInstructionMatchAt("CheckStackOverflow", 3, 5);
+ spt.FuzzyInstructionMatchAt("Constant(#Field", 4, 11);
+ spt.FuzzyInstructionMatchAt("LoadStaticField", 4, 11);
+ spt.FuzzyInstructionMatchAt("StoreLocal(:switch_expr", 4, 11);
+
+ spt.FuzzyInstructionMatchAt("Constant(#1", 5, 10);
+ spt.FuzzyInstructionMatchAt("LoadLocal(:switch_expr", 5, 5); // 'c'
+ spt.InstanceCallAt(5, 10, Token::kEQ); // '1'
+
+ spt.FuzzyInstructionMatchAt("Constant(#3", 5, 20); // '3'
+ spt.FuzzyInstructionMatchAt("DebugStepCheck", 5, 13);
+ spt.FuzzyInstructionMatchAt("Return", 5, 13);
+
+ spt.FuzzyInstructionMatchAt("Constant(#2", 6, 10);
+ spt.FuzzyInstructionMatchAt("LoadLocal(:switch_expr", 6, 5); // 'c'
+ spt.InstanceCallAt(6, 10, Token::kEQ); // '1'
rmacnak 2016/01/12 22:59:21 '1' => '2'
Cutch 2016/01/12 23:02:15 Done.
+
+ spt.FuzzyInstructionMatchAt("Constant(#4", 6, 20); // '4'
+ spt.FuzzyInstructionMatchAt("DebugStepCheck", 6, 13);
+ spt.FuzzyInstructionMatchAt("Return", 6, 13);
+
+ spt.FuzzyInstructionMatchAt("Constant(#5", 7, 21); // '5'
+ spt.FuzzyInstructionMatchAt("DebugStepCheck", 7, 14);
+ spt.FuzzyInstructionMatchAt("Return", 7, 14);
+}
+
+
+TEST_CASE(SourcePosition_TryCatchFinally) {
+ const char* kScript =
+ "var x = 5;\n"
+ "var y = 5;\n"
+ "main() {\n"
+ " try {\n"
+ " throw 'A';\n"
+ " } catch (e) {\n"
+ " print(e);\n"
+ " return 77;\n"
+ " } finally {\n"
+ " return 99;\n"
+ " }\n"
+ "}\n";
+
+ SourcePositionTest spt(thread, kScript);
+ spt.BuildGraphFor("main");
+
+ spt.FuzzyInstructionMatchAt("DebugStepCheck", 3, 5);
+ spt.FuzzyInstructionMatchAt("CheckStackOverflow", 3, 5);
+
+ spt.FuzzyInstructionMatchAt("LoadLocal(:current_context", 4, 3); // 't'
+ spt.FuzzyInstructionMatchAt("StoreLocal(:saved_try_context", 4, 3);
+
+ spt.FuzzyInstructionMatchAt("Constant(#A", 5, 11); // 'A'
+ spt.FuzzyInstructionMatchAt("Throw", 5, 5); // 't'
+
+ spt.FuzzyInstructionMatchAt("LoadLocal(:saved_try_context", 6, 5); // 'c'
+ spt.FuzzyInstructionMatchAt("StoreLocal(:current_context", 6, 5); // 'c'
+ spt.FuzzyInstructionMatchAt("LoadLocal(:exception_var", 6, 5); // 'c'
+ spt.FuzzyInstructionMatchAt("StoreLocal(e", 6, 5); // 'c'
+
+ spt.FuzzyInstructionMatchAt("LoadLocal(e", 7, 11); // 'e'
+
+ spt.FuzzyInstructionMatchAt("StaticCall", 7, 5); // 'p'
+
+ spt.FuzzyInstructionMatchAt("Constant(#77", 8, 12); // '7'
+ spt.FuzzyInstructionMatchAt("StoreLocal(:finally_ret_val", 8, 5); // 'r'
+
+ spt.FuzzyInstructionMatchAt("Constant(#99", 10, 12); // '9'
+ spt.FuzzyInstructionMatchAt("Return", 10, 5); // 'r'
+
+ spt.FuzzyInstructionMatchAt("LoadLocal(:saved_try_context", 9, 13); // '{'
+ spt.FuzzyInstructionMatchAt("StoreLocal(:current_context", 9, 13); // '{'
+
+ spt.FuzzyInstructionMatchAt("Constant(#99", 10, 12); // '9'
+ spt.FuzzyInstructionMatchAt("Return", 10, 5); // 'r'
+}
+
} // namespace dart
« 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