OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/execution.h" | 7 #include "src/execution.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 3827 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
3828 auto callable = tester.GetCallable<>(); | 3828 auto callable = tester.GetCallable<>(); |
3829 | 3829 |
3830 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3830 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3831 CHECK(return_value->SameValue(*do_expr[i].second)); | 3831 CHECK(return_value->SameValue(*do_expr[i].second)); |
3832 } | 3832 } |
3833 | 3833 |
3834 FLAG_harmony_do_expressions = old_flag; | 3834 FLAG_harmony_do_expressions = old_flag; |
3835 } | 3835 } |
3836 | 3836 |
| 3837 TEST(InterpreterWithStatement) { |
| 3838 HandleAndZoneScope handles; |
| 3839 i::Isolate* isolate = handles.main_isolate(); |
| 3840 |
| 3841 std::pair<const char*, Handle<Object>> with_stmt[] = { |
| 3842 {"with({x:42}) return x;", handle(Smi::FromInt(42), isolate)}, |
| 3843 {"with({}) { var y = 10; return y;}", handle(Smi::FromInt(10), isolate)}, |
| 3844 {"var y = {x:42};" |
| 3845 " function inner() {" |
| 3846 " var x = 20;" |
| 3847 " with(y) return x;" |
| 3848 "}" |
| 3849 "return inner();", |
| 3850 handle(Smi::FromInt(42), isolate)}, |
| 3851 {"var y = {x:42};" |
| 3852 " function inner(o) {" |
| 3853 " var x = 20;" |
| 3854 " with(o) return x;" |
| 3855 "}" |
| 3856 "return inner(y);", |
| 3857 handle(Smi::FromInt(42), isolate)}, |
| 3858 }; |
| 3859 |
| 3860 for (size_t i = 0; i < arraysize(with_stmt); i++) { |
| 3861 std::string source(InterpreterTester::SourceForBody(with_stmt[i].first)); |
| 3862 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
| 3863 auto callable = tester.GetCallable<>(); |
| 3864 |
| 3865 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3866 CHECK(return_value->SameValue(*with_stmt[i].second)); |
| 3867 } |
| 3868 } |
| 3869 |
3837 } // namespace interpreter | 3870 } // namespace interpreter |
3838 } // namespace internal | 3871 } // namespace internal |
3839 } // namespace v8 | 3872 } // namespace v8 |
OLD | NEW |