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

Unified Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1402093002: [Interpreter]: Add fake support for try/catch/finally. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/test262/testcfg.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 7d2f527fe29757612e7d0e406cf984d0d110f86c..c4150d98306e85d53106e8516644f5835393250d 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -65,6 +65,7 @@ class InterpreterTester {
feedback_vector_(feedback_vector) {
i::FLAG_vector_stores = true;
i::FLAG_ignition = true;
+ i::FLAG_ignition_fake_try_catch = true;
i::FLAG_always_opt = false;
// Set ignition filter flag via SetFlagsFromString to avoid double-free
// (or potential leak with StrDup() based on ownership confusion).
@@ -1672,3 +1673,31 @@ TEST(InterpreterArrayLiterals) {
CHECK(return_value->SameValue(*literals[i].second));
}
}
+
+
+TEST(InterpreterTryCatch) {
+ HandleAndZoneScope handles;
+
+ // TODO(rmcilroy): modify tests when we have real try catch support.
+ std::string source(InterpreterTester::SourceForBody(
+ "var a = 1; try { a = a + 1; } catch(e) { a = a + 2; }; return a;"));
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<Object> return_val = callable().ToHandleChecked();
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(2));
+}
+
+
+TEST(InterpreterTryFinally) {
+ HandleAndZoneScope handles;
+
+ // TODO(rmcilroy): modify tests when we have real try finally support.
+ std::string source(InterpreterTester::SourceForBody(
+ "var a = 1; try { a = a + 1; } finally { a = a + 2; }; return a;"));
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<Object> return_val = callable().ToHandleChecked();
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(4));
+}
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/test262/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698