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

Side by Side Diff: test/codegen/expect/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, 4 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
« no previous file with comments | « test/codegen/async_helper.dart ('k') | test/codegen/expect/async_helper.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 dart_library.library('async_helper', null, /* Imports */[
2 "dart_runtime/dart",
3 'dart/core',
4 'dart/isolate'
5 ], /* Lazy imports */[
6 ], function(exports, dart, core, isolate) {
7 'use strict';
8 let dartx = dart.dartx;
9 exports._initialized = false;
10 exports._port = null;
11 exports._asyncLevel = 0;
12 function _buildException(msg) {
13 return core.Exception.new(`Fatal: ${msg}. This is most likely a bug in your test.`);
14 }
15 dart.fn(_buildException, core.Exception, [core.String]);
16 function asyncStart() {
17 if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) {
18 dart.throw(_buildException('asyncStart() was called even though we are don e ' + 'with testing.'));
19 }
20 if (!dart.notNull(exports._initialized)) {
21 core.print('unittest-suite-wait-for-done');
22 exports._initialized = true;
23 exports._port = isolate.ReceivePort.new();
24 }
25 exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1;
26 }
27 dart.fn(asyncStart, dart.void, []);
28 function asyncEnd() {
29 if (dart.notNull(exports._asyncLevel) <= 0) {
30 if (!dart.notNull(exports._initialized)) {
31 dart.throw(_buildException('asyncEnd() was called before asyncStart().') );
32 } else {
33 dart.throw(_buildException('asyncEnd() was called more often than ' + 'a syncStart().'));
34 }
35 }
36 exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1;
37 if (exports._asyncLevel == 0) {
38 exports._port.close();
39 exports._port = null;
40 core.print('unittest-suite-success');
41 }
42 }
43 dart.fn(asyncEnd, dart.void, []);
44 function asyncSuccess(_) {
45 return asyncEnd();
46 }
47 dart.fn(asyncSuccess, dart.void, [dart.dynamic]);
48 function asyncTest(f) {
49 asyncStart();
50 dart.dsend(f(), 'then', asyncSuccess);
51 }
52 dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]);
53 // Exports:
54 exports.asyncStart = asyncStart;
55 exports.asyncEnd = asyncEnd;
56 exports.asyncSuccess = asyncSuccess;
57 exports.asyncTest = asyncTest;
58 });
OLDNEW
« no previous file with comments | « test/codegen/async_helper.dart ('k') | test/codegen/expect/async_helper.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698