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

Unified Diff: test/mjsunit/harmony/generators-iteration.js

Issue 141363005: A64: Synchronize with r15204. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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
« no previous file with comments | « test/mjsunit/compiler/inline-arguments.js ('k') | test/mjsunit/harmony/generators-runtime.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/generators-iteration.js
diff --git a/test/mjsunit/harmony/generators-iteration.js b/test/mjsunit/harmony/generators-iteration.js
index 01facd085c27ad41660fa8c5af56657da4b3afde..dc210d5b1167521c833365e4a120ed8a6fc45439 100644
--- a/test/mjsunit/harmony/generators-iteration.js
+++ b/test/mjsunit/harmony/generators-iteration.js
@@ -324,6 +324,58 @@ TestGenerator(
"foo",
[2, "1foo3", 5, "4foo6", "foofoo"]);
+// Generator function instances.
+TestGenerator(GeneratorFunction(),
+ [undefined],
+ "foo",
+ [undefined]);
+
+TestGenerator(new GeneratorFunction(),
+ [undefined],
+ "foo",
+ [undefined]);
+
+TestGenerator(GeneratorFunction('yield 1;'),
+ [1, undefined],
+ "foo",
+ [1, undefined]);
+
+TestGenerator(
+ function() { return GeneratorFunction('x', 'y', 'yield x + y;')(1, 2) },
+ [3, undefined],
+ "foo",
+ [3, undefined]);
+
+// Test that yield* re-yields received results without re-boxing.
+function TestDelegatingYield() {
+ function results(results) {
+ var i = 0;
+ function next() {
+ return results[i++];
+ }
+ return { next: next }
+ }
+ function* yield_results(expected) {
+ return yield* results(expected);
+ }
+ function collect_results(iter) {
+ var ret = [];
+ var result;
+ do {
+ result = iter.next();
+ ret.push(result);
+ } while (!result.done);
+ return ret;
+ }
+ // We have to put a full result for the end, because the return will re-box.
+ var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
+
+ // Sanity check.
+ assertEquals(expected, collect_results(results(expected)));
+ assertEquals(expected, collect_results(yield_results(expected)));
+}
+TestDelegatingYield();
+
function TestTryCatch(instantiate) {
function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; }
function Sentinel() {}
« no previous file with comments | « test/mjsunit/compiler/inline-arguments.js ('k') | test/mjsunit/harmony/generators-runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698