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

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

Issue 1656863002: [Interpreter] Adds support for with statement to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Skips a failing test on arm64. 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
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index d3c031f740a2807f92e6a6e4bf11bc8222692def..0471980e6695f4b60fe075b9bed9c14ef7676f74 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -3834,6 +3834,39 @@ TEST(InterpreterDoExpression) {
FLAG_harmony_do_expressions = old_flag;
}
+TEST(InterpreterWithStatement) {
+ HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
+
+ std::pair<const char*, Handle<Object>> with_stmt[] = {
+ {"with({x:42}) return x;", handle(Smi::FromInt(42), isolate)},
+ {"with({}) { var y = 10; return y;}", handle(Smi::FromInt(10), isolate)},
+ {"var y = {x:42};"
+ " function inner() {"
+ " var x = 20;"
+ " with(y) return x;"
rmcilroy 2016/02/02 17:05:23 nit - remove extra space
mythria 2016/02/03 12:21:34 Done.
+ "}"
+ "return inner();",
+ handle(Smi::FromInt(42), isolate)},
+ {"var y = {x:42};"
+ " function inner(o) {"
+ " var x = 20;"
+ " with(o) return x;"
rmcilroy 2016/02/02 17:05:23 ditto
mythria 2016/02/03 12:21:34 Done.
+ "}"
+ "return inner(y);",
+ handle(Smi::FromInt(42), isolate)},
+ };
+
+ for (size_t i = 0; i < arraysize(with_stmt); i++) {
+ std::string source(InterpreterTester::SourceForBody(with_stmt[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(*with_stmt[i].second));
+ }
+}
rmcilroy 2016/02/02 17:05:23 Could you add these tests to test-run-bytecode-gra
mythria 2016/02/03 12:21:34 Done.
+
} // namespace interpreter
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698