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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index c8dc776010933d1d430455f0b27b540d77a12cd5..49089664089da0ae731003a1438690deeeab0c2c 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -4139,6 +4139,37 @@ TEST(InterpreterIllegalConstDeclaration) {
}
}
+TEST(InterpreterGenerators) {
+ bool old_flag = FLAG_ignition_generators;
+ FLAG_ignition_generators = true;
+
+ HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
+ i::Factory* factory = isolate->factory();
+
+ std::pair<const char*, Handle<Object>> tests[] = {
+ {"function* f() { }; return f().next().value",
+ factory->undefined_value()},
+ {"function* f() { yield 42 }; return f().next().value",
+ factory->NewNumberFromInt(42)},
+ {"function* f() { for (let x of [42]) yield x}; return f().next().value",
+ factory->NewNumberFromInt(42)},
+ };
+
+ for (size_t i = 0; i < arraysize(tests); i++) {
+ std::string source(
+ InterpreterTester::SourceForBody(tests[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(*tests[i].second));
+ }
+
+ FLAG_ignition_generators = old_flag;
+}
+
+
} // namespace interpreter
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698