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

Unified Diff: test/codegen/expect/syncstar_yield_test.js

Issue 1207313002: initial sync*, part of #221 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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/codegen/expect/syncstar_syntax.txt ('k') | test/codegen/expect/syncstar_yield_test.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/expect/syncstar_yield_test.js
diff --git a/test/codegen/expect/syncstar_yield_test.js b/test/codegen/expect/syncstar_yield_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..c4f40302926bf129fe6db4672d2d3cfd22d6f924
--- /dev/null
+++ b/test/codegen/expect/syncstar_yield_test.js
@@ -0,0 +1,59 @@
+dart_library.library('syncstar_yield_test', null, /* Imports */[
+ "dart_runtime/dart",
+ 'dart/core',
+ 'expect'
+], /* Lazy imports */[
+], function(exports, dart, core, expect) {
+ 'use strict';
+ let dartx = dart.dartx;
+ function* foo1() {
+ yield 1;
+ }
+ dart.fn(foo1, core.Iterable$(core.int), []);
+ function* foo2(p) {
+ let t = false;
+ yield null;
+ while (true) {
+ a:
+ for (let i = 0; dart.notNull(i) < dart.notNull(dart.as(p, core.num)); i = dart.notNull(i) + 1) {
+ if (!dart.notNull(t)) {
+ for (let j = 0; dart.notNull(j) < 3; j = dart.notNull(j) + 1) {
+ yield -1;
+ t = true;
+ break a;
+ }
+ }
+ yield i;
+ }
+ }
+ }
+ dart.fn(foo2, core.Iterable$(core.int), [dart.dynamic]);
+ function* foo3(p) {
+ let i = 0;
+ i = dart.notNull(i) + 1;
+ p = dart.notNull(p) + 1;
+ yield dart.notNull(p) + dart.notNull(i);
+ }
+ dart.fn(foo3, core.Iterable$(core.int), [core.int]);
+ function main() {
+ expect.Expect.listEquals([1], foo1()[dartx.toList]());
+ expect.Expect.listEquals([null, -1, 0, 1, 2, 3, 0, 1, 2, 3], foo2(4)[dartx.take](10)[dartx.toList]());
+ let t = foo3(0);
+ let it1 = t[dartx.iterator];
+ let it2 = t[dartx.iterator];
+ it1.moveNext();
+ it2.moveNext();
+ expect.Expect.equals(2, it1.current);
+ expect.Expect.equals(2, it2.current);
+ expect.Expect.isFalse(it1.moveNext());
+ expect.Expect.isFalse(it1.moveNext());
+ expect.Expect.isFalse(it2.moveNext());
+ expect.Expect.isFalse(it2.moveNext());
+ }
+ dart.fn(main);
+ // Exports:
+ exports.foo1 = foo1;
+ exports.foo2 = foo2;
+ exports.foo3 = foo3;
+ exports.main = main;
+});
« no previous file with comments | « test/codegen/expect/syncstar_syntax.txt ('k') | test/codegen/expect/syncstar_yield_test.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698