Chromium Code Reviews| 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 |