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

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

Issue 1605633003: [interpreter] First implementation of stack unwinding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_int-5
Patch Set: Rebase and skip one more test. 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 | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/mjsunit/mjsunit.status » ('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 3f93bee2ed33b0f63103762680303635da61119e..ea28cc95b250f25423b83262d7ddcb0032d59018 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -2021,15 +2021,25 @@ TEST(InterpreterLogicalAnd) {
TEST(InterpreterTryCatch) {
HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
- // 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<>();
+ std::pair<const char*, Handle<Object>> catches[] = {
+ std::make_pair("var a = 1; try { a = 2 } catch(e) { a = 3 }; return a;",
+ handle(Smi::FromInt(2), isolate)),
+ std::make_pair("var a; try { undef.x } catch(e) { a = 2 }; return a;",
+ handle(Smi::FromInt(2), isolate)),
+ std::make_pair("var a; try { throw 1 } catch(e) { a = e + 2 }; return a;",
+ handle(Smi::FromInt(3), isolate)),
+ };
- Handle<Object> return_val = callable().ToHandleChecked();
- CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(2));
+ for (size_t i = 0; i < arraysize(catches); i++) {
+ std::string source(InterpreterTester::SourceForBody(catches[i].first));
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<i::Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*catches[i].second));
+ }
}
@@ -2052,7 +2062,6 @@ TEST(InterpreterThrow) {
i::Isolate* isolate = handles.main_isolate();
i::Factory* factory = isolate->factory();
- // TODO(rmcilroy): modify tests when we have real try catch support.
std::pair<const char*, Handle<Object>> throws[] = {
std::make_pair("throw undefined;\n",
factory->undefined_value()),
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698