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

Side by Side Diff: test/codegen/expect/async_helper.js

Issue 1355893003: Rewire DDC to use the analyzer task model (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 dart_library.library('async_helper', null, /* Imports */[ 1 dart_library.library('async_helper', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/core' 3 'dart/core'
4 ], /* Lazy imports */[ 4 ], /* Lazy imports */[
5 ], function(exports, dart, core) { 5 ], function(exports, dart, core) {
6 'use strict'; 6 'use strict';
7 let dartx = dart.dartx; 7 let dartx = dart.dartx;
8 exports._initialized = false; 8 exports._initialized = false;
9 let _Action0 = dart.typedef('_Action0', () => dart.functionType(dart.void, []) ); 9 let _Action0 = dart.typedef('_Action0', () => dart.functionType(dart.void, []) );
10 exports._onAsyncEnd = null; 10 exports._onAsyncEnd = null;
11 exports._asyncLevel = 0; 11 exports._asyncLevel = 0;
12 function _buildException(msg) { 12 function _buildException(msg) {
13 return core.Exception.new(`Fatal: ${msg}. This is most likely a bug in your test.`); 13 return core.Exception.new(`Fatal: ${msg}. This is most likely a bug in your test.`);
14 } 14 }
15 dart.fn(_buildException, core.Exception, [core.String]); 15 dart.fn(_buildException, core.Exception, [core.String]);
16 function asyncTestInitialize(callback) { 16 function asyncTestInitialize(callback) {
17 exports._asyncLevel = 0; 17 exports._asyncLevel = 0;
18 exports._initialized = false; 18 exports._initialized = false;
19 exports._onAsyncEnd = callback; 19 exports._onAsyncEnd = callback;
20 } 20 }
21 dart.fn(asyncTestInitialize, dart.void, [_Action0]); 21 dart.fn(asyncTestInitialize, dart.void, [_Action0]);
22 dart.copyProperties(exports, { 22 dart.copyProperties(exports, {
23 get asyncTestStarted() { 23 get asyncTestStarted() {
24 return exports._initialized; 24 return exports._initialized;
25 } 25 }
26 }); 26 });
27 function asyncStart() { 27 function asyncStart() {
28 if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) { 28 if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) {
29 dart.throw(_buildException('asyncStart() was called even though we are don e ' + 'with testing.')); 29 dart.throw(dart.dcall(_buildException, 'asyncStart() was called even thoug h we are done ' + 'with testing.'));
30 } 30 }
31 if (!dart.notNull(exports._initialized)) { 31 if (!dart.notNull(exports._initialized)) {
32 if (exports._onAsyncEnd == null) { 32 if (exports._onAsyncEnd == null) {
33 dart.throw(_buildException('asyncStart() was called before asyncTestInit ialize()')); 33 dart.throw(dart.dcall(_buildException, 'asyncStart() was called before a syncTestInitialize()'));
34 } 34 }
35 core.print('unittest-suite-wait-for-done'); 35 dart.dcall(core.print, 'unittest-suite-wait-for-done');
36 exports._initialized = true; 36 exports._initialized = true;
37 } 37 }
38 exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1; 38 exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1;
39 } 39 }
40 dart.fn(asyncStart, dart.void, []); 40 dart.fn(asyncStart, dart.void, []);
41 function asyncEnd() { 41 function asyncEnd() {
42 if (dart.notNull(exports._asyncLevel) <= 0) { 42 if (dart.notNull(exports._asyncLevel) <= 0) {
43 if (!dart.notNull(exports._initialized)) { 43 if (!dart.notNull(exports._initialized)) {
44 dart.throw(_buildException('asyncEnd() was called before asyncStart().') ); 44 dart.throw(dart.dcall(_buildException, 'asyncEnd() was called before asy ncStart().'));
45 } else { 45 } else {
46 dart.throw(_buildException('asyncEnd() was called more often than ' + 'a syncStart().')); 46 dart.throw(dart.dcall(_buildException, 'asyncEnd() was called more often than ' + 'asyncStart().'));
47 } 47 }
48 } 48 }
49 exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1; 49 exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1;
50 if (exports._asyncLevel == 0) { 50 if (exports._asyncLevel == 0) {
51 let callback = exports._onAsyncEnd; 51 let callback = exports._onAsyncEnd;
52 exports._onAsyncEnd = null; 52 exports._onAsyncEnd = null;
53 callback(); 53 callback();
54 core.print('unittest-suite-success'); 54 dart.dcall(core.print, 'unittest-suite-success');
55 } 55 }
56 } 56 }
57 dart.fn(asyncEnd, dart.void, []); 57 dart.fn(asyncEnd, dart.void, []);
58 function asyncSuccess(_) { 58 function asyncSuccess(_) {
59 return asyncEnd(); 59 return dart.dcall(asyncEnd);
60 } 60 }
61 dart.fn(asyncSuccess, dart.void, [dart.dynamic]); 61 dart.fn(asyncSuccess, dart.void, [dart.dynamic]);
62 function asyncTest(f) { 62 function asyncTest(f) {
63 asyncStart(); 63 dart.dcall(asyncStart);
64 dart.dsend(f(), 'then', asyncSuccess); 64 dart.dsend(f(), 'then', asyncSuccess);
65 } 65 }
66 dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]); 66 dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]);
67 // Exports: 67 // Exports:
68 exports.asyncTestInitialize = asyncTestInitialize; 68 exports.asyncTestInitialize = asyncTestInitialize;
69 exports.asyncStart = asyncStart; 69 exports.asyncStart = asyncStart;
70 exports.asyncEnd = asyncEnd; 70 exports.asyncEnd = asyncEnd;
71 exports.asyncSuccess = asyncSuccess; 71 exports.asyncSuccess = asyncSuccess;
72 exports.asyncTest = asyncTest; 72 exports.asyncTest = asyncTest;
73 }); 73 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698