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

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

Issue 1289673007: fixes #292, report async_helper test failures (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
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 'dart/isolate'
5 ], /* Lazy imports */[ 4 ], /* Lazy imports */[
6 ], function(exports, dart, core, isolate) { 5 ], function(exports, dart, core) {
7 'use strict'; 6 'use strict';
8 let dartx = dart.dartx; 7 let dartx = dart.dartx;
9 exports._initialized = false; 8 exports._initialized = false;
10 exports._port = null; 9 exports._onAsyncEnd = null;
11 exports._asyncLevel = 0; 10 exports._asyncLevel = 0;
12 function _buildException(msg) { 11 function _buildException(msg) {
13 return core.Exception.new(`Fatal: ${msg}. This is most likely a bug in your test.`); 12 return core.Exception.new(`Fatal: ${msg}. This is most likely a bug in your test.`);
14 } 13 }
15 dart.fn(_buildException, core.Exception, [core.String]); 14 dart.fn(_buildException, core.Exception, [core.String]);
15 function asyncTestInitialize(callback) {
16 exports._asyncLevel = 0;
17 exports._initialized = false;
18 exports._onAsyncEnd = callback;
19 }
20 dart.fn(asyncTestInitialize, dart.void, [dart.functionType(dart.void, [])]);
21 dart.copyProperties(exports, {
22 get asyncTestStarted() {
23 return exports._initialized;
24 }
25 });
16 function asyncStart() { 26 function asyncStart() {
17 if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) { 27 if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) {
18 dart.throw(_buildException('asyncStart() was called even though we are don e ' + 'with testing.')); 28 dart.throw(_buildException('asyncStart() was called even though we are don e ' + 'with testing.'));
19 } 29 }
20 if (!dart.notNull(exports._initialized)) { 30 if (!dart.notNull(exports._initialized)) {
31 if (exports._onAsyncEnd == null) {
32 dart.throw(_buildException('asyncStart() was called before asyncTestInit ialize()'));
33 }
21 core.print('unittest-suite-wait-for-done'); 34 core.print('unittest-suite-wait-for-done');
22 exports._initialized = true; 35 exports._initialized = true;
23 exports._port = isolate.ReceivePort.new();
24 } 36 }
25 exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1; 37 exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1;
26 } 38 }
27 dart.fn(asyncStart, dart.void, []); 39 dart.fn(asyncStart, dart.void, []);
28 function asyncEnd() { 40 function asyncEnd() {
29 if (dart.notNull(exports._asyncLevel) <= 0) { 41 if (dart.notNull(exports._asyncLevel) <= 0) {
30 if (!dart.notNull(exports._initialized)) { 42 if (!dart.notNull(exports._initialized)) {
31 dart.throw(_buildException('asyncEnd() was called before asyncStart().') ); 43 dart.throw(_buildException('asyncEnd() was called before asyncStart().') );
32 } else { 44 } else {
33 dart.throw(_buildException('asyncEnd() was called more often than ' + 'a syncStart().')); 45 dart.throw(_buildException('asyncEnd() was called more often than ' + 'a syncStart().'));
34 } 46 }
35 } 47 }
36 exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1; 48 exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1;
37 if (exports._asyncLevel == 0) { 49 if (exports._asyncLevel == 0) {
38 exports._port.close(); 50 let callback = exports._onAsyncEnd;
39 exports._port = null; 51 exports._onAsyncEnd = null;
52 dart.dcall(callback);
40 core.print('unittest-suite-success'); 53 core.print('unittest-suite-success');
41 } 54 }
42 } 55 }
43 dart.fn(asyncEnd, dart.void, []); 56 dart.fn(asyncEnd, dart.void, []);
44 function asyncSuccess(_) { 57 function asyncSuccess(_) {
45 return asyncEnd(); 58 return asyncEnd();
46 } 59 }
47 dart.fn(asyncSuccess, dart.void, [dart.dynamic]); 60 dart.fn(asyncSuccess, dart.void, [dart.dynamic]);
48 function asyncTest(f) { 61 function asyncTest(f) {
49 asyncStart(); 62 asyncStart();
50 dart.dsend(f(), 'then', asyncSuccess); 63 dart.dsend(f(), 'then', asyncSuccess);
51 } 64 }
52 dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]); 65 dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]);
53 // Exports: 66 // Exports:
67 exports.asyncTestInitialize = asyncTestInitialize;
54 exports.asyncStart = asyncStart; 68 exports.asyncStart = asyncStart;
55 exports.asyncEnd = asyncEnd; 69 exports.asyncEnd = asyncEnd;
56 exports.asyncSuccess = asyncSuccess; 70 exports.asyncSuccess = asyncSuccess;
57 exports.asyncTest = asyncTest; 71 exports.asyncTest = asyncTest;
58 }); 72 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698