| OLD | NEW | 
|---|
| 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   let _Action0 = dart.typedef('_Action0', () => dart.functionType(dart.void, [])
    ); | 
|  | 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) { | 
|  | 17     exports._asyncLevel = 0; | 
|  | 18     exports._initialized = false; | 
|  | 19     exports._onAsyncEnd = callback; | 
|  | 20   } | 
|  | 21   dart.fn(asyncTestInitialize, dart.void, [_Action0]); | 
|  | 22   dart.copyProperties(exports, { | 
|  | 23     get asyncTestStarted() { | 
|  | 24       return exports._initialized; | 
|  | 25     } | 
|  | 26   }); | 
| 16   function asyncStart() { | 27   function asyncStart() { | 
| 17     if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) { | 28     if (dart.notNull(exports._initialized) && exports._asyncLevel == 0) { | 
| 18       dart.throw(_buildException('asyncStart() was called even though we are don
    e ' + 'with testing.')); | 29       dart.throw(_buildException('asyncStart() was called even though we are don
    e ' + 'with testing.')); | 
| 19     } | 30     } | 
| 20     if (!dart.notNull(exports._initialized)) { | 31     if (!dart.notNull(exports._initialized)) { | 
|  | 32       if (exports._onAsyncEnd == null) { | 
|  | 33         dart.throw(_buildException('asyncStart() was called before asyncTestInit
    ialize()')); | 
|  | 34       } | 
| 21       core.print('unittest-suite-wait-for-done'); | 35       core.print('unittest-suite-wait-for-done'); | 
| 22       exports._initialized = true; | 36       exports._initialized = true; | 
| 23       exports._port = isolate.ReceivePort.new(); |  | 
| 24     } | 37     } | 
| 25     exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1; | 38     exports._asyncLevel = dart.notNull(exports._asyncLevel) + 1; | 
| 26   } | 39   } | 
| 27   dart.fn(asyncStart, dart.void, []); | 40   dart.fn(asyncStart, dart.void, []); | 
| 28   function asyncEnd() { | 41   function asyncEnd() { | 
| 29     if (dart.notNull(exports._asyncLevel) <= 0) { | 42     if (dart.notNull(exports._asyncLevel) <= 0) { | 
| 30       if (!dart.notNull(exports._initialized)) { | 43       if (!dart.notNull(exports._initialized)) { | 
| 31         dart.throw(_buildException('asyncEnd() was called before asyncStart().')
    ); | 44         dart.throw(_buildException('asyncEnd() was called before asyncStart().')
    ); | 
| 32       } else { | 45       } else { | 
| 33         dart.throw(_buildException('asyncEnd() was called more often than ' + 'a
    syncStart().')); | 46         dart.throw(_buildException('asyncEnd() was called more often than ' + 'a
    syncStart().')); | 
| 34       } | 47       } | 
| 35     } | 48     } | 
| 36     exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1; | 49     exports._asyncLevel = dart.notNull(exports._asyncLevel) - 1; | 
| 37     if (exports._asyncLevel == 0) { | 50     if (exports._asyncLevel == 0) { | 
| 38       exports._port.close(); | 51       let callback = exports._onAsyncEnd; | 
| 39       exports._port = null; | 52       exports._onAsyncEnd = null; | 
|  | 53       callback(); | 
| 40       core.print('unittest-suite-success'); | 54       core.print('unittest-suite-success'); | 
| 41     } | 55     } | 
| 42   } | 56   } | 
| 43   dart.fn(asyncEnd, dart.void, []); | 57   dart.fn(asyncEnd, dart.void, []); | 
| 44   function asyncSuccess(_) { | 58   function asyncSuccess(_) { | 
| 45     return asyncEnd(); | 59     return asyncEnd(); | 
| 46   } | 60   } | 
| 47   dart.fn(asyncSuccess, dart.void, [dart.dynamic]); | 61   dart.fn(asyncSuccess, dart.void, [dart.dynamic]); | 
| 48   function asyncTest(f) { | 62   function asyncTest(f) { | 
| 49     asyncStart(); | 63     asyncStart(); | 
| 50     dart.dsend(f(), 'then', asyncSuccess); | 64     dart.dsend(f(), 'then', asyncSuccess); | 
| 51   } | 65   } | 
| 52   dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]); | 66   dart.fn(asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]); | 
| 53   // Exports: | 67   // Exports: | 
|  | 68   exports.asyncTestInitialize = asyncTestInitialize; | 
| 54   exports.asyncStart = asyncStart; | 69   exports.asyncStart = asyncStart; | 
| 55   exports.asyncEnd = asyncEnd; | 70   exports.asyncEnd = asyncEnd; | 
| 56   exports.asyncSuccess = asyncSuccess; | 71   exports.asyncSuccess = asyncSuccess; | 
| 57   exports.asyncTest = asyncTest; | 72   exports.asyncTest = asyncTest; | 
| 58 }); | 73 }); | 
| OLD | NEW | 
|---|