OLD | NEW |
1 define(['dart_sdk'], function(dart_sdk) { | 1 define(['dart_sdk'], function(dart_sdk) { |
2 'use strict'; | 2 'use strict'; |
3 const core = dart_sdk.core; | 3 const core = dart_sdk.core; |
4 const dart = dart_sdk.dart; | 4 const dart = dart_sdk.dart; |
5 const dartx = dart_sdk.dartx; | 5 const dartx = dart_sdk.dartx; |
6 const async_helper = Object.create(null); | 6 const async_helper = Object.create(null); |
7 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.fnTypeFuzzy(dart.
dynamic, [])))(); | 7 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.fnTypeFuzzy(dart.
dynamic, [])))(); |
8 let StringToException = () => (StringToException = dart.constFn(dart.fnType(co
re.Exception, [core.String])))(); | 8 let StringToException = () => (StringToException = dart.constFn(dart.fnType(co
re.Exception, [core.String])))(); |
9 let _Action0Tovoid = () => (_Action0Tovoid = dart.constFn(dart.fnType(dart.voi
d, [async_helper._Action0])))(); | 9 let _Action0Tovoid = () => (_Action0Tovoid = dart.constFn(dart.fnType(dart.voi
d, [async_helper._Action0])))(); |
10 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.fnType(dart.void, [])))
(); | 10 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.fnType(dart.void, [])))
(); |
(...skipping 25 matching lines...) Expand all Loading... |
36 async_helper._initialized = false; | 36 async_helper._initialized = false; |
37 async_helper._onAsyncEnd = callback; | 37 async_helper._onAsyncEnd = callback; |
38 }; | 38 }; |
39 dart.fn(async_helper.asyncTestInitialize, _Action0Tovoid()); | 39 dart.fn(async_helper.asyncTestInitialize, _Action0Tovoid()); |
40 dart.copyProperties(async_helper, { | 40 dart.copyProperties(async_helper, { |
41 get asyncTestStarted() { | 41 get asyncTestStarted() { |
42 return async_helper._initialized; | 42 return async_helper._initialized; |
43 } | 43 } |
44 }); | 44 }); |
45 async_helper.asyncStart = function() { | 45 async_helper.asyncStart = function() { |
46 if (dart.test(async_helper._initialized) && async_helper._asyncLevel == 0) { | 46 if (dart.test(async_helper._initialized) && async_helper._asyncLevel === 0)
{ |
47 dart.throw(async_helper._buildException('asyncStart() was called even thou
gh we are done ' + 'with testing.')); | 47 dart.throw(async_helper._buildException('asyncStart() was called even thou
gh we are done ' + 'with testing.')); |
48 } | 48 } |
49 if (!dart.test(async_helper._initialized)) { | 49 if (!dart.test(async_helper._initialized)) { |
50 if (async_helper._onAsyncEnd == null) { | 50 if (async_helper._onAsyncEnd == null) { |
51 dart.throw(async_helper._buildException('asyncStart() was called before
asyncTestInitialize()')); | 51 dart.throw(async_helper._buildException('asyncStart() was called before
asyncTestInitialize()')); |
52 } | 52 } |
53 core.print('unittest-suite-wait-for-done'); | 53 core.print('unittest-suite-wait-for-done'); |
54 async_helper._initialized = true; | 54 async_helper._initialized = true; |
55 } | 55 } |
56 async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) + 1; | 56 async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) + 1; |
57 }; | 57 }; |
58 dart.fn(async_helper.asyncStart, VoidTovoid()); | 58 dart.fn(async_helper.asyncStart, VoidTovoid()); |
59 async_helper.asyncEnd = function() { | 59 async_helper.asyncEnd = function() { |
60 if (dart.notNull(async_helper._asyncLevel) <= 0) { | 60 if (dart.notNull(async_helper._asyncLevel) <= 0) { |
61 if (!dart.test(async_helper._initialized)) { | 61 if (!dart.test(async_helper._initialized)) { |
62 dart.throw(async_helper._buildException('asyncEnd() was called before as
yncStart().')); | 62 dart.throw(async_helper._buildException('asyncEnd() was called before as
yncStart().')); |
63 } else { | 63 } else { |
64 dart.throw(async_helper._buildException('asyncEnd() was called more ofte
n than ' + 'asyncStart().')); | 64 dart.throw(async_helper._buildException('asyncEnd() was called more ofte
n than ' + 'asyncStart().')); |
65 } | 65 } |
66 } | 66 } |
67 async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) - 1; | 67 async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) - 1; |
68 if (async_helper._asyncLevel == 0) { | 68 if (async_helper._asyncLevel === 0) { |
69 let callback = async_helper._onAsyncEnd; | 69 let callback = async_helper._onAsyncEnd; |
70 async_helper._onAsyncEnd = null; | 70 async_helper._onAsyncEnd = null; |
71 callback(); | 71 callback(); |
72 core.print('unittest-suite-success'); | 72 core.print('unittest-suite-success'); |
73 } | 73 } |
74 }; | 74 }; |
75 dart.fn(async_helper.asyncEnd, VoidTovoid()); | 75 dart.fn(async_helper.asyncEnd, VoidTovoid()); |
76 async_helper.asyncSuccess = function(_) { | 76 async_helper.asyncSuccess = function(_) { |
77 return async_helper.asyncEnd(); | 77 return async_helper.asyncEnd(); |
78 }; | 78 }; |
79 dart.fn(async_helper.asyncSuccess, dynamicTovoid()); | 79 dart.fn(async_helper.asyncSuccess, dynamicTovoid()); |
80 async_helper.asyncTest = function(f) { | 80 async_helper.asyncTest = function(f) { |
81 async_helper.asyncStart(); | 81 async_helper.asyncStart(); |
82 dart.dsend(f(), 'then', async_helper.asyncSuccess); | 82 dart.dsend(f(), 'then', async_helper.asyncSuccess); |
83 }; | 83 }; |
84 dart.fn(async_helper.asyncTest, FnTovoid()); | 84 dart.fn(async_helper.asyncTest, FnTovoid()); |
85 dart.trackLibraries("async_helper", { | 85 dart.trackLibraries("async_helper", { |
86 "async_helper.dart": async_helper | 86 "async_helper.dart": async_helper |
87 }, null); | 87 }, null); |
88 // Exports: | 88 // Exports: |
89 return { | 89 return { |
90 async_helper: async_helper | 90 async_helper: async_helper |
91 }; | 91 }; |
92 }); | 92 }); |
OLD | NEW |