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 3732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3743 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 3743 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
3744 auto callable = tester.GetCallable<>(); | 3744 auto callable = tester.GetCallable<>(); |
3745 | 3745 |
3746 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3746 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3747 CHECK(return_value->SameValue(*do_expr[i].second)); | 3747 CHECK(return_value->SameValue(*do_expr[i].second)); |
3748 } | 3748 } |
3749 | 3749 |
3750 FLAG_harmony_do_expressions = old_flag; | 3750 FLAG_harmony_do_expressions = old_flag; |
3751 } | 3751 } |
3752 | 3752 |
| 3753 TEST(InterpreterWithStatement) { |
| 3754 HandleAndZoneScope handles; |
| 3755 i::Isolate* isolate = handles.main_isolate(); |
| 3756 |
| 3757 std::pair<const char*, Handle<Object>> with_stmt[] = { |
| 3758 {"with({x:42}) return x;", handle(Smi::FromInt(42), isolate)}, |
| 3759 {"with({}) { var y = 10; return y;}", handle(Smi::FromInt(10), isolate)}, |
| 3760 {"var y = {x:42};" |
| 3761 " function inner() {" |
| 3762 " var x = 20;" |
| 3763 " with(y) return x;" |
| 3764 "}" |
| 3765 "return inner();", |
| 3766 handle(Smi::FromInt(42), isolate)}, |
| 3767 {"var y = {x:42};" |
| 3768 " function inner(o) {" |
| 3769 " var x = 20;" |
| 3770 " with(o) return x;" |
| 3771 "}" |
| 3772 "return inner(y);", |
| 3773 handle(Smi::FromInt(42), isolate)}, |
| 3774 }; |
| 3775 |
| 3776 for (size_t i = 0; i < arraysize(with_stmt); i++) { |
| 3777 std::string source(InterpreterTester::SourceForBody(with_stmt[i].first)); |
| 3778 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
| 3779 auto callable = tester.GetCallable<>(); |
| 3780 |
| 3781 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3782 CHECK(return_value->SameValue(*with_stmt[i].second)); |
| 3783 } |
| 3784 } |
| 3785 |
3753 } // namespace interpreter | 3786 } // namespace interpreter |
3754 } // namespace internal | 3787 } // namespace internal |
3755 } // namespace v8 | 3788 } // namespace v8 |
OLD | NEW |