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

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1884183002: First version of the new generators implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 4121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4132 std::string source(InterpreterTester::SourceForBody(strict_body.c_str())); 4132 std::string source(InterpreterTester::SourceForBody(strict_body.c_str()));
4133 InterpreterTester tester(handles.main_isolate(), source.c_str()); 4133 InterpreterTester tester(handles.main_isolate(), source.c_str());
4134 v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); 4134 v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get();
4135 v8::Local<v8::String> expected_string = v8_str(const_decl[i].second); 4135 v8::Local<v8::String> expected_string = v8_str(const_decl[i].second);
4136 CHECK( 4136 CHECK(
4137 message->Equals(CcTest::isolate()->GetCurrentContext(), expected_string) 4137 message->Equals(CcTest::isolate()->GetCurrentContext(), expected_string)
4138 .FromJust()); 4138 .FromJust());
4139 } 4139 }
4140 } 4140 }
4141 4141
4142 TEST(InterpreterGenerators) {
4143 bool old_flag = FLAG_ignition_generators;
4144 FLAG_ignition_generators = true;
4145
4146 HandleAndZoneScope handles;
4147 i::Isolate* isolate = handles.main_isolate();
4148 i::Factory* factory = isolate->factory();
4149
4150 std::pair<const char*, Handle<Object>> tests[] = {
4151 {"function* f() { }; return f().next().value",
4152 factory->undefined_value()},
4153 {"function* f() { yield 42 }; return f().next().value",
4154 factory->NewNumberFromInt(42)},
4155 {"function* f() { for (let x of [42]) yield x}; return f().next().value",
4156 factory->NewNumberFromInt(42)},
4157 };
4158
4159 for (size_t i = 0; i < arraysize(tests); i++) {
4160 std::string source(
4161 InterpreterTester::SourceForBody(tests[i].first));
4162 InterpreterTester tester(handles.main_isolate(), source.c_str());
4163 auto callable = tester.GetCallable<>();
4164
4165 Handle<i::Object> return_value = callable().ToHandleChecked();
4166 CHECK(return_value->SameValue(*tests[i].second));
4167 }
4168
4169 FLAG_ignition_generators = old_flag;
4170 }
4171
4172
4142 } // namespace interpreter 4173 } // namespace interpreter
4143 } // namespace internal 4174 } // namespace internal
4144 } // namespace v8 4175 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698