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

Unified Diff: test/cctest/compiler/test-run-jsexceptions.cc

Issue 873423004: First stab at try-catch and try-finally in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed moarer comments by Ben Titzer. Created 5 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 | « src/flag-definitions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-jsexceptions.cc
diff --git a/test/cctest/compiler/test-run-jsexceptions.cc b/test/cctest/compiler/test-run-jsexceptions.cc
index 0712ab62057d742eef946eb74b3c4cc0a6e5e0ab..43ce91b56b6928a5b0de65fc0dd66472a7e51edf 100644
--- a/test/cctest/compiler/test-run-jsexceptions.cc
+++ b/test/cctest/compiler/test-run-jsexceptions.cc
@@ -43,3 +43,117 @@ TEST(ThrowSourcePosition) {
CHECK_EQ(4, message->GetLineNumber());
CHECK_EQ(95, message->GetStartPosition());
}
+
+
+// TODO(mstarzinger): Increase test coverage by having similar tests within the
+// mjsunit suite to also test integration with other components (e.g. OSR).
+
+
+TEST(Catch) {
+ i::FLAG_turbo_exceptions = true;
+ const char* src =
+ "(function(a,b) {"
+ " var r = '-';"
+ " try {"
+ " r += 'A-';"
+ " throw 'B-';"
+ " } catch (e) {"
+ " r += e;"
+ " }"
+ " return r;"
+ "})";
+ FunctionTester T(src);
+
+ T.CheckCall(T.Val("-A-B-"));
+}
+
+
+TEST(CatchNested) {
+ i::FLAG_turbo_exceptions = true;
+ const char* src =
+ "(function(a,b) {"
+ " var r = '-';"
+ " try {"
+ " r += 'A-';"
+ " throw 'C-';"
+ " } catch (e) {"
+ " try {"
+ " throw 'B-';"
+ " } catch (e) {"
+ " r += e;"
+ " }"
+ " r += e;"
+ " }"
+ " return r;"
+ "})";
+ FunctionTester T(src);
+
+ T.CheckCall(T.Val("-A-B-C-"));
+}
+
+
+TEST(CatchBreak) {
+ i::FLAG_turbo_exceptions = true;
+ const char* src =
+ "(function(a,b) {"
+ " var r = '-';"
+ " L: try {"
+ " r += 'A-';"
+ " if (a) break L;"
+ " r += 'B-';"
+ " throw 'C-';"
+ " } catch (e) {"
+ " if (b) break L;"
+ " r += e;"
+ " }"
+ " r += 'D-';"
+ " return r;"
+ "})";
+ FunctionTester T(src);
+
+ T.CheckCall(T.Val("-A-D-"), T.true_value(), T.false_value());
+ T.CheckCall(T.Val("-A-B-D-"), T.false_value(), T.true_value());
+ T.CheckCall(T.Val("-A-B-C-D-"), T.false_value(), T.false_value());
+}
+
+
+TEST(Finally) {
+ i::FLAG_turbo_exceptions = true;
+ const char* src =
+ "(function(a,b) {"
+ " var r = '-';"
+ " try {"
+ " r += 'A-';"
+ " } finally {"
+ " r += 'B-';"
+ " }"
+ " return r;"
+ "})";
+ FunctionTester T(src);
+
+ T.CheckCall(T.Val("-A-B-"));
+}
+
+
+TEST(FinallyBreak) {
+ i::FLAG_turbo_exceptions = true;
+ const char* src =
+ "(function(a,b) {"
+ " var r = '-';"
+ " L: try {"
+ " r += 'A-';"
+ " if (a) return r;"
+ " r += 'B-';"
+ " if (b) break L;"
+ " r += 'C-';"
+ " } finally {"
+ " r += 'D-';"
+ " }"
+ " return r;"
+ "})";
+ FunctionTester T(src);
+
+ T.CheckCall(T.Val("-A-"), T.true_value(), T.false_value());
+ T.CheckCall(T.Val("-A-B-D-"), T.false_value(), T.true_value());
+ T.CheckCall(T.Val("-A-B-C-D-"), T.false_value(), T.false_value());
+}
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698