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

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

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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/async_helper.txt ('k') | test/codegen/expect/dom/dom.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/expect/async_helper/async_helper.js
diff --git a/test/codegen/expect/async_helper/async_helper.js b/test/codegen/expect/async_helper/async_helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..da7324ec1a4b403ff855b834c6ab95e30bc8d9e3
--- /dev/null
+++ b/test/codegen/expect/async_helper/async_helper.js
@@ -0,0 +1,58 @@
+dart_library.library('async_helper/async_helper', null, /* Imports */[
+ "dart_runtime/dart",
+ 'dart/core',
+ 'dart/isolate'
+], /* Lazy imports */[
+], function(exports, dart, core, isolate) {
+ 'use strict';
+ let dartx = dart.dartx;
+ exports._initialized = false;
+ exports._port = null;
+ exports._asyncLevel = 0;
+ function _buildException(msg) {
+ return core.Exception.new(`Fatal: ${msg}. This is most likely a bug in your test.`);
+ }
+ dart.fn(_buildException, core.Exception, [core.String]);
+ function asyncStart() {
+ if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) {
+ dart.throw(_buildException('asyncStart() was called even though we are done ' + 'with testing.'));
+ }
+ if (!dart.notNull(exports._initialized)) {
+ core.print('unittest-suite-wait-for-done');
+ exports._initialized = true;
+ exports._port = isolate.ReceivePort.new();
+ }
+ exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1;
+ }
+ dart.fn(asyncStart, dart.void, []);
+ function asyncEnd() {
+ if (dart.notNull(exports._asyncLevel) <= 0) {
+ if (!dart.notNull(exports._initialized)) {
+ dart.throw(_buildException('asyncEnd() was called before asyncStart().'));
+ } else {
+ dart.throw(_buildException('asyncEnd() was called more often than ' + 'asyncStart().'));
+ }
+ }
+ exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1;
+ if (exports._asyncLevel == 0) {
+ exports._port.close();
+ exports._port = null;
+ core.print('unittest-suite-success');
+ }
+ }
+ dart.fn(asyncEnd, dart.void, []);
+ function asyncSuccess(_) {
+ return asyncEnd();
+ }
+ dart.fn(asyncSuccess, dart.void, [dart.dynamic]);
+ function asyncTest(f) {
+ asyncStart();
+ dart.dsend(f(), 'then', asyncSuccess);
+ }
+ dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]);
+ // Exports:
+ exports.asyncStart = asyncStart;
+ exports.asyncEnd = asyncEnd;
+ exports.asyncSuccess = asyncSuccess;
+ exports.asyncTest = asyncTest;
+});
« no previous file with comments | « test/codegen/expect/async_helper.txt ('k') | test/codegen/expect/dom/dom.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698