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/bytecode-array-iterator.h" | 10 #include "src/interpreter/bytecode-array-iterator.h" |
(...skipping 4136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4147 std::pair<const char*, Handle<Object>> tests[] = { | 4147 std::pair<const char*, Handle<Object>> tests[] = { |
4148 {"function* f() { }; return f().next().value", | 4148 {"function* f() { }; return f().next().value", |
4149 factory->undefined_value()}, | 4149 factory->undefined_value()}, |
4150 {"function* f() { yield 42 }; return f().next().value", | 4150 {"function* f() { yield 42 }; return f().next().value", |
4151 factory->NewNumberFromInt(42)}, | 4151 factory->NewNumberFromInt(42)}, |
4152 {"function* f() { for (let x of [42]) yield x}; return f().next().value", | 4152 {"function* f() { for (let x of [42]) yield x}; return f().next().value", |
4153 factory->NewNumberFromInt(42)}, | 4153 factory->NewNumberFromInt(42)}, |
4154 }; | 4154 }; |
4155 | 4155 |
4156 for (size_t i = 0; i < arraysize(tests); i++) { | 4156 for (size_t i = 0; i < arraysize(tests); i++) { |
4157 std::string source( | 4157 std::string source(InterpreterTester::SourceForBody(tests[i].first)); |
4158 InterpreterTester::SourceForBody(tests[i].first)); | |
4159 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 4158 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
4160 auto callable = tester.GetCallable<>(); | 4159 auto callable = tester.GetCallable<>(); |
4161 | 4160 |
4162 Handle<i::Object> return_value = callable().ToHandleChecked(); | 4161 Handle<i::Object> return_value = callable().ToHandleChecked(); |
4163 CHECK(return_value->SameValue(*tests[i].second)); | 4162 CHECK(return_value->SameValue(*tests[i].second)); |
4164 } | 4163 } |
4165 | 4164 |
4166 FLAG_ignition_generators = old_flag; | 4165 FLAG_ignition_generators = old_flag; |
4167 } | 4166 } |
4168 | 4167 |
4169 | |
4170 } // namespace interpreter | 4168 } // namespace interpreter |
4171 } // namespace internal | 4169 } // namespace internal |
4172 } // namespace v8 | 4170 } // namespace v8 |
OLD | NEW |