| OLD | NEW |
| 1 library angular.mock.zone_spec; | 1 library angular.mock.zone_spec; |
| 2 | 2 |
| 3 import '../_specs.dart'; | 3 import '../_specs.dart'; |
| 4 import 'dart:async'; | 4 import 'dart:async'; |
| 5 | 5 |
| 6 main() => describe('mock zones', () { | 6 void main() { |
| 7 describe('sync', () { | 7 describe('mock zones', () { |
| 8 it('should throw an error on scheduleMicrotask', () { | 8 describe('sync', () { |
| 9 expect(sync(() { | 9 it('should throw an error on scheduleMicrotask', () { |
| 10 scheduleMicrotask(() => dump("i never run")); | 10 expect(sync(() { |
| 11 })).toThrow('scheduleMicrotask called from sync function'); | 11 scheduleMicrotask(() => dump("i never run")); |
| 12 })).toThrow('scheduleMicrotask called from sync function'); |
| 13 }); |
| 14 |
| 15 |
| 16 it('should throw an error on timer', () { |
| 17 expect(sync(() { |
| 18 Timer.run(() => dump("i never run")); |
| 19 })).toThrow('Timer created from sync function'); |
| 20 }); |
| 21 |
| 22 |
| 23 it('should throw an error on periodic timer', () { |
| 24 expect(sync(() { |
| 25 new Timer.periodic(new Duration(milliseconds: 10), |
| 26 (_) => dump("i never run")); |
| 27 })).toThrow('periodic Timer created from sync function'); |
| 28 }); |
| 12 }); | 29 }); |
| 13 | 30 |
| 14 | 31 describe('async', () { |
| 15 it('should throw an error on timer', () { | 32 it('should run synchronous code', () { |
| 16 expect(sync(() { | 33 var ran = false; |
| 17 Timer.run(() => dump("i never run")); | 34 async(() { ran = true; })(); |
| 18 })).toThrow('Timer created from sync function'); | 35 expect(ran).toBe(true); |
| 19 }); | 36 }); |
| 20 | 37 |
| 21 | 38 |
| 22 it('should throw an error on periodic timer', () { | 39 it('should run async code', () { |
| 23 expect(sync(() { | 40 var ran = false; |
| 24 new Timer.periodic(new Duration(milliseconds: 10), | 41 var thenRan = false; |
| 25 (_) => dump("i never run")); | 42 async(() { |
| 26 })).toThrow('periodic Timer created from sync function'); | 43 new Future.value('s').then((_) { thenRan = true; }); |
| 44 expect(thenRan).toBe(false); |
| 45 expect(isAsyncQueueEmpty()).toBe(false); |
| 46 microLeap(); |
| 47 expect(isAsyncQueueEmpty()).toBe(true); |
| 48 expect(thenRan).toBe(true); |
| 49 ran = true; |
| 50 })(); |
| 51 expect(ran).toBe(true); |
| 52 }); |
| 53 |
| 54 |
| 55 it('should run async code with scheduleMicrotask', () { |
| 56 var ran = false; |
| 57 var thenRan = false; |
| 58 async(() { |
| 59 scheduleMicrotask(() { thenRan = true; }); |
| 60 expect(thenRan).toBe(false); |
| 61 microLeap(); |
| 62 expect(thenRan).toBe(true); |
| 63 ran = true; |
| 64 })(); |
| 65 expect(ran).toBe(true); |
| 66 }); |
| 67 |
| 68 |
| 69 it('should run chained thens', () { |
| 70 var log = []; |
| 71 async(() { |
| 72 new Future.value('s') |
| 73 .then((_) { log.add('firstThen'); }) |
| 74 .then((_) { log.add('2ndThen'); }); |
| 75 expect(log.join(' ')).toEqual(''); |
| 76 microLeap(); |
| 77 expect(log.join(' ')).toEqual('firstThen 2ndThen'); |
| 78 })(); |
| 79 }); |
| 80 |
| 81 |
| 82 it('shold run futures created in futures', () { |
| 83 var log = []; |
| 84 async(() { |
| 85 new Future.value('s') |
| 86 .then((_) { |
| 87 log.add('firstThen'); |
| 88 new Future.value('t').then((_) { |
| 89 log.add('2ndThen'); |
| 90 }); |
| 91 }); |
| 92 expect(log.join(' ')).toEqual(''); |
| 93 microLeap(); |
| 94 expect(log.join(' ')).toEqual('firstThen 2ndThen'); |
| 95 })(); |
| 96 }); |
| 97 |
| 98 it('should run all the async calls if asked', () { |
| 99 var log = []; |
| 100 async(() { |
| 101 new Future.value('s') |
| 102 .then((_) { |
| 103 log.add('firstThen'); |
| 104 new Future.value('t').then((_) { |
| 105 log.add('2ndThen'); |
| 106 }); |
| 107 }); |
| 108 expect(log.join(' ')).toEqual(''); |
| 109 microLeap(); |
| 110 expect(log.join(' ')).toEqual('firstThen 2ndThen'); |
| 111 })(); |
| 112 }); |
| 113 |
| 114 |
| 115 it('should not complain if you dangle callbacks', () { |
| 116 async(() { |
| 117 new Future.value("s").then((_) {}); |
| 118 })(); |
| 119 }); |
| 120 |
| 121 |
| 122 it('should complain if you dangle exceptions', () { |
| 123 expect(() { |
| 124 async(() { |
| 125 new Future.value("s").then((_) { |
| 126 throw ["dangling"]; |
| 127 }); |
| 128 })(); |
| 129 }).toThrow("dangling"); |
| 130 }); |
| 131 |
| 132 |
| 133 it('should complain if the test throws an exception', () { |
| 134 expect(() { |
| 135 async(() { |
| 136 throw "blah"; |
| 137 })(); |
| 138 }).toThrow("blah"); |
| 139 }); |
| 140 |
| 141 |
| 142 it('should complain if the test throws an exception during async calls', (
) { |
| 143 expect(async(() { |
| 144 new Future.value('s').then((_) { throw "blah then"; }); |
| 145 microLeap(); |
| 146 })).toThrow("blah then"); |
| 147 }); |
| 148 |
| 149 it('should throw errors from the microLeap call', async(() { |
| 150 new Future.value('s').then((_) { throw "blah then 2"; }); |
| 151 expect(() { |
| 152 microLeap(); |
| 153 }).toThrow("blah then 2"); |
| 154 })); |
| 155 |
| 156 describe('timers', () { |
| 157 it('should not run queued timer on insufficient clock tick', async(() { |
| 158 bool timerRan = false; |
| 159 var timer = new Timer(new Duration(milliseconds: 10), |
| 160 () => timerRan = true); |
| 161 |
| 162 clockTick(milliseconds: 9); |
| 163 expect(timerRan).toBeFalsy(); |
| 164 |
| 165 timer.cancel(); |
| 166 })); |
| 167 |
| 168 |
| 169 it('should run queued zero duration timer on zero tick', async(() { |
| 170 bool timerRan = false; |
| 171 Timer.run(() => timerRan = true); |
| 172 |
| 173 clockTick(); |
| 174 expect(timerRan).toBeTruthy(); |
| 175 })); |
| 176 |
| 177 |
| 178 it('should run queued timer after sufficient clock ticks', async(() { |
| 179 bool timerRan = false; |
| 180 new Timer(new Duration(milliseconds: 10), () => timerRan = true); |
| 181 |
| 182 clockTick(milliseconds: 9); |
| 183 expect(timerRan).toBeFalsy(); |
| 184 clockTick(milliseconds: 1); |
| 185 expect(timerRan).toBeTruthy(); |
| 186 })); |
| 187 |
| 188 |
| 189 it('should run queued timer only once', async(() { |
| 190 int timerRan = 0; |
| 191 new Timer(new Duration(milliseconds: 10), () => timerRan++); |
| 192 |
| 193 clockTick(milliseconds: 10); |
| 194 expect(timerRan).toBe(1); |
| 195 clockTick(milliseconds: 10); |
| 196 expect(timerRan).toBe(1); |
| 197 clockTick(minutes: 10); |
| 198 expect(timerRan).toBe(1); |
| 199 })); |
| 200 |
| 201 |
| 202 it('should run periodic timer', async(() { |
| 203 int timerRan = 0; |
| 204 var timer = new Timer.periodic(new Duration(milliseconds: 10), |
| 205 (_) => timerRan++); |
| 206 |
| 207 clockTick(milliseconds: 9); |
| 208 expect(timerRan).toBe(0); |
| 209 clockTick(milliseconds: 1); |
| 210 expect(timerRan).toBe(1); |
| 211 clockTick(milliseconds: 30); |
| 212 expect(timerRan).toBe(4); |
| 213 |
| 214 timer.cancel(); |
| 215 })); |
| 216 |
| 217 |
| 218 it('should not run cancelled timer', async(() { |
| 219 bool timerRan = false; |
| 220 var timer = new Timer(new Duration(milliseconds: 10), |
| 221 () => timerRan = true); |
| 222 |
| 223 timer.cancel(); |
| 224 |
| 225 clockTick(milliseconds: 10); |
| 226 expect(timerRan).toBeFalsy(); |
| 227 })); |
| 228 |
| 229 |
| 230 it('should not run cancelled periodic timer', async(() { |
| 231 bool timerRan = false; |
| 232 var timer = new Timer.periodic(new Duration(milliseconds: 10), |
| 233 (_) => timerRan = true); |
| 234 |
| 235 timer.cancel(); |
| 236 |
| 237 clockTick(milliseconds: 10); |
| 238 expect(timerRan).toBeFalsy(); |
| 239 })); |
| 240 |
| 241 |
| 242 it('should be able to cancel periodic timer from callback', async(() { |
| 243 int timerRan = 0; |
| 244 var timer = new Timer.periodic(new Duration(milliseconds: 10), |
| 245 (t) { |
| 246 timerRan++; |
| 247 t.cancel(); |
| 248 }); |
| 249 |
| 250 clockTick(milliseconds: 10); |
| 251 expect(timerRan).toBe(1); |
| 252 |
| 253 clockTick(milliseconds: 10); |
| 254 expect(timerRan).toBe(1); |
| 255 |
| 256 timer.cancel(); |
| 257 })); |
| 258 |
| 259 |
| 260 it('should process micro-tasks before timers', async(() { |
| 261 var log = []; |
| 262 |
| 263 scheduleMicrotask(() => log.add('scheduleMicrotask')); |
| 264 new Timer(new Duration(milliseconds: 10), |
| 265 () => log.add('timer')); |
| 266 var timer = new Timer.periodic(new Duration(milliseconds: 10), |
| 267 (_) => log.add('periodic_timer')); |
| 268 |
| 269 expect(log.join(' ')).toEqual(''); |
| 270 |
| 271 clockTick(milliseconds: 10); |
| 272 |
| 273 expect(log.join(' ')).toEqual('scheduleMicrotask timer periodic_timer'
); |
| 274 |
| 275 timer.cancel(); |
| 276 })); |
| 277 |
| 278 |
| 279 it('should process micro-tasks created in timers before next timers', as
ync(() { |
| 280 var log = []; |
| 281 |
| 282 scheduleMicrotask(() => log.add('scheduleMicrotask')); |
| 283 new Timer(new Duration(milliseconds: 10), |
| 284 () { |
| 285 log.add('timer'); |
| 286 scheduleMicrotask(() => log.add('timer_scheduleMicrotask')); |
| 287 }); |
| 288 var timer = new Timer.periodic(new Duration(milliseconds: 10), |
| 289 (_) { |
| 290 log.add('periodic_timer'); |
| 291 scheduleMicrotask(() => log.add('periodic_timer_scheduleMicrotask'))
; |
| 292 }); |
| 293 |
| 294 expect(log.join(' ')).toEqual(''); |
| 295 |
| 296 clockTick(milliseconds: 10); |
| 297 expect(log.join(' ')).toEqual('scheduleMicrotask timer timer_scheduleM
icrotask periodic_timer'); |
| 298 |
| 299 clockTick(); |
| 300 expect(log.join(' ')).toEqual('scheduleMicrotask timer timer_scheduleM
icrotask periodic_timer'); |
| 301 |
| 302 clockTick(milliseconds: 10); |
| 303 expect(log.join(' ')).toEqual('scheduleMicrotask timer timer_scheduleM
icrotask periodic_timer periodic_timer_scheduleMicrotask periodic_timer'); |
| 304 |
| 305 timer.cancel(); |
| 306 })); |
| 307 |
| 308 |
| 309 it('should not leak timers between asyncs', () { |
| 310 var log = []; |
| 311 |
| 312 async(() { |
| 313 var timer = new Timer.periodic(new Duration(milliseconds: 10), |
| 314 (_) => log.add('periodic_timer')); |
| 315 new Timer(new Duration(milliseconds: 10), |
| 316 () => log.add('timer')); |
| 317 clockTick(milliseconds: 10); |
| 318 timer.cancel(); |
| 319 })(); |
| 320 expect(log.join(' ')).toEqual('periodic_timer timer'); |
| 321 |
| 322 async(() { |
| 323 clockTick(milliseconds: 10); |
| 324 })(); |
| 325 expect(log.join(' ')).toEqual('periodic_timer timer'); |
| 326 }); |
| 327 |
| 328 |
| 329 it('should throw an error on dangling timers', () { |
| 330 expect(async(() { |
| 331 new Timer.periodic(new Duration(milliseconds: 10), |
| 332 (_) => dump("i never run")); |
| 333 })).toThrow('1 active timer(s) are still in the queue.'); |
| 334 }); |
| 335 }); |
| 27 }); | 336 }); |
| 28 }); | 337 }); |
| 29 | 338 } |
| 30 describe('async', () { | |
| 31 it('should run synchronous code', () { | |
| 32 var ran = false; | |
| 33 async(() { ran = true; })(); | |
| 34 expect(ran).toBe(true); | |
| 35 }); | |
| 36 | |
| 37 | |
| 38 it('should run async code', () { | |
| 39 var ran = false; | |
| 40 var thenRan = false; | |
| 41 async(() { | |
| 42 new Future.value('s').then((_) { thenRan = true; }); | |
| 43 expect(thenRan).toBe(false); | |
| 44 microLeap(); | |
| 45 expect(thenRan).toBe(true); | |
| 46 ran = true; | |
| 47 })(); | |
| 48 expect(ran).toBe(true); | |
| 49 }); | |
| 50 | |
| 51 | |
| 52 it('should run async code with scheduleMicrotask', () { | |
| 53 var ran = false; | |
| 54 var thenRan = false; | |
| 55 async(() { | |
| 56 scheduleMicrotask(() { thenRan = true; }); | |
| 57 expect(thenRan).toBe(false); | |
| 58 microLeap(); | |
| 59 expect(thenRan).toBe(true); | |
| 60 ran = true; | |
| 61 })(); | |
| 62 expect(ran).toBe(true); | |
| 63 }); | |
| 64 | |
| 65 | |
| 66 it('should run chained thens', () { | |
| 67 var log = []; | |
| 68 async(() { | |
| 69 new Future.value('s') | |
| 70 .then((_) { log.add('firstThen'); }) | |
| 71 .then((_) { log.add('2ndThen'); }); | |
| 72 expect(log.join(' ')).toEqual(''); | |
| 73 microLeap(); | |
| 74 expect(log.join(' ')).toEqual('firstThen 2ndThen'); | |
| 75 })(); | |
| 76 }); | |
| 77 | |
| 78 | |
| 79 it('shold run futures created in futures', () { | |
| 80 var log = []; | |
| 81 async(() { | |
| 82 new Future.value('s') | |
| 83 .then((_) { | |
| 84 log.add('firstThen'); | |
| 85 new Future.value('t').then((_) { | |
| 86 log.add('2ndThen'); | |
| 87 }); | |
| 88 }); | |
| 89 expect(log.join(' ')).toEqual(''); | |
| 90 microLeap(); | |
| 91 expect(log.join(' ')).toEqual('firstThen 2ndThen'); | |
| 92 })(); | |
| 93 }); | |
| 94 | |
| 95 it('should run all the async calls if asked', () { | |
| 96 var log = []; | |
| 97 async(() { | |
| 98 new Future.value('s') | |
| 99 .then((_) { | |
| 100 log.add('firstThen'); | |
| 101 new Future.value('t').then((_) { | |
| 102 log.add('2ndThen'); | |
| 103 }); | |
| 104 }); | |
| 105 expect(log.join(' ')).toEqual(''); | |
| 106 microLeap(); | |
| 107 expect(log.join(' ')).toEqual('firstThen 2ndThen'); | |
| 108 })(); | |
| 109 }); | |
| 110 | |
| 111 | |
| 112 it('should not complain if you dangle callbacks', () { | |
| 113 async(() { | |
| 114 new Future.value("s").then((_) {}); | |
| 115 })(); | |
| 116 }); | |
| 117 | |
| 118 | |
| 119 it('should complain if you dangle exceptions', () { | |
| 120 expect(() { | |
| 121 async(() { | |
| 122 new Future.value("s").then((_) { | |
| 123 throw ["dangling"]; | |
| 124 }); | |
| 125 })(); | |
| 126 }).toThrow("dangling"); | |
| 127 }); | |
| 128 | |
| 129 | |
| 130 it('should complain if the test throws an exception', () { | |
| 131 expect(() { | |
| 132 async(() { | |
| 133 throw "blah"; | |
| 134 })(); | |
| 135 }).toThrow("blah"); | |
| 136 }); | |
| 137 | |
| 138 | |
| 139 it('should complain if the test throws an exception during async calls', ()
{ | |
| 140 expect(async(() { | |
| 141 new Future.value('s').then((_) { throw "blah then"; }); | |
| 142 microLeap(); | |
| 143 })).toThrow("blah then"); | |
| 144 }); | |
| 145 | |
| 146 it('should throw errors from the microLeap call', async(() { | |
| 147 new Future.value('s').then((_) { throw "blah then 2"; }); | |
| 148 expect(() { | |
| 149 microLeap(); | |
| 150 }).toThrow("blah then 2"); | |
| 151 })); | |
| 152 | |
| 153 describe('timers', () { | |
| 154 it('should not run queued timer on insufficient clock tick', async(() { | |
| 155 bool timerRan = false; | |
| 156 var timer = new Timer(new Duration(milliseconds: 10), | |
| 157 () => timerRan = true); | |
| 158 | |
| 159 clockTick(milliseconds: 9); | |
| 160 expect(timerRan).toBeFalsy(); | |
| 161 | |
| 162 timer.cancel(); | |
| 163 })); | |
| 164 | |
| 165 | |
| 166 it('should run queued zero duration timer on zero tick', async(() { | |
| 167 bool timerRan = false; | |
| 168 Timer.run(() => timerRan = true); | |
| 169 | |
| 170 clockTick(); | |
| 171 expect(timerRan).toBeTruthy(); | |
| 172 })); | |
| 173 | |
| 174 | |
| 175 it('should run queued timer after sufficient clock ticks', async(() { | |
| 176 bool timerRan = false; | |
| 177 new Timer(new Duration(milliseconds: 10), () => timerRan = true); | |
| 178 | |
| 179 clockTick(milliseconds: 9); | |
| 180 expect(timerRan).toBeFalsy(); | |
| 181 clockTick(milliseconds: 1); | |
| 182 expect(timerRan).toBeTruthy(); | |
| 183 })); | |
| 184 | |
| 185 | |
| 186 it('should run queued timer only once', async(() { | |
| 187 int timerRan = 0; | |
| 188 new Timer(new Duration(milliseconds: 10), () => timerRan++); | |
| 189 | |
| 190 clockTick(milliseconds: 10); | |
| 191 expect(timerRan).toBe(1); | |
| 192 clockTick(milliseconds: 10); | |
| 193 expect(timerRan).toBe(1); | |
| 194 clockTick(minutes: 10); | |
| 195 expect(timerRan).toBe(1); | |
| 196 })); | |
| 197 | |
| 198 | |
| 199 it('should run periodic timer', async(() { | |
| 200 int timerRan = 0; | |
| 201 var timer = new Timer.periodic(new Duration(milliseconds: 10), | |
| 202 (_) => timerRan++); | |
| 203 | |
| 204 clockTick(milliseconds: 9); | |
| 205 expect(timerRan).toBe(0); | |
| 206 clockTick(milliseconds: 1); | |
| 207 expect(timerRan).toBe(1); | |
| 208 clockTick(milliseconds: 30); | |
| 209 expect(timerRan).toBe(4); | |
| 210 | |
| 211 timer.cancel(); | |
| 212 })); | |
| 213 | |
| 214 | |
| 215 it('should not run cancelled timer', async(() { | |
| 216 bool timerRan = false; | |
| 217 var timer = new Timer(new Duration(milliseconds: 10), | |
| 218 () => timerRan = true); | |
| 219 | |
| 220 timer.cancel(); | |
| 221 | |
| 222 clockTick(milliseconds: 10); | |
| 223 expect(timerRan).toBeFalsy(); | |
| 224 })); | |
| 225 | |
| 226 | |
| 227 it('should not run cancelled periodic timer', async(() { | |
| 228 bool timerRan = false; | |
| 229 var timer = new Timer.periodic(new Duration(milliseconds: 10), | |
| 230 (_) => timerRan = true); | |
| 231 | |
| 232 timer.cancel(); | |
| 233 | |
| 234 clockTick(milliseconds: 10); | |
| 235 expect(timerRan).toBeFalsy(); | |
| 236 })); | |
| 237 | |
| 238 | |
| 239 it('should be able to cancel periodic timer from callback', async(() { | |
| 240 int timerRan = 0; | |
| 241 var timer = new Timer.periodic(new Duration(milliseconds: 10), | |
| 242 (t) { | |
| 243 timerRan++; | |
| 244 t.cancel(); | |
| 245 }); | |
| 246 | |
| 247 clockTick(milliseconds: 10); | |
| 248 expect(timerRan).toBe(1); | |
| 249 | |
| 250 clockTick(milliseconds: 10); | |
| 251 expect(timerRan).toBe(1); | |
| 252 | |
| 253 timer.cancel(); | |
| 254 })); | |
| 255 | |
| 256 | |
| 257 it('should process micro-tasks before timers', async(() { | |
| 258 var log = []; | |
| 259 | |
| 260 scheduleMicrotask(() => log.add('scheduleMicrotask')); | |
| 261 new Timer(new Duration(milliseconds: 10), | |
| 262 () => log.add('timer')); | |
| 263 var timer = new Timer.periodic(new Duration(milliseconds: 10), | |
| 264 (_) => log.add('periodic_timer')); | |
| 265 | |
| 266 expect(log.join(' ')).toEqual(''); | |
| 267 | |
| 268 clockTick(milliseconds: 10); | |
| 269 | |
| 270 expect(log.join(' ')).toEqual('scheduleMicrotask timer periodic_timer'); | |
| 271 | |
| 272 timer.cancel(); | |
| 273 })); | |
| 274 | |
| 275 | |
| 276 it('should process micro-tasks created in timers before next timers', asyn
c(() { | |
| 277 var log = []; | |
| 278 | |
| 279 scheduleMicrotask(() => log.add('scheduleMicrotask')); | |
| 280 new Timer(new Duration(milliseconds: 10), | |
| 281 () { | |
| 282 log.add('timer'); | |
| 283 scheduleMicrotask(() => log.add('timer_scheduleMicrotask')); | |
| 284 }); | |
| 285 var timer = new Timer.periodic(new Duration(milliseconds: 10), | |
| 286 (_) { | |
| 287 log.add('periodic_timer'); | |
| 288 scheduleMicrotask(() => log.add('periodic_timer_scheduleMicrotask'
)); | |
| 289 }); | |
| 290 | |
| 291 expect(log.join(' ')).toEqual(''); | |
| 292 | |
| 293 clockTick(milliseconds: 10); | |
| 294 expect(log.join(' ')).toEqual('scheduleMicrotask timer timer_scheduleMic
rotask periodic_timer'); | |
| 295 | |
| 296 clockTick(); | |
| 297 expect(log.join(' ')).toEqual('scheduleMicrotask timer timer_scheduleMic
rotask periodic_timer'); | |
| 298 | |
| 299 clockTick(milliseconds: 10); | |
| 300 expect(log.join(' ')).toEqual('scheduleMicrotask timer timer_scheduleMic
rotask periodic_timer periodic_timer_scheduleMicrotask periodic_timer'); | |
| 301 | |
| 302 timer.cancel(); | |
| 303 })); | |
| 304 | |
| 305 | |
| 306 it('should not leak timers between asyncs', () { | |
| 307 var log = []; | |
| 308 | |
| 309 async(() { | |
| 310 var timer = new Timer.periodic(new Duration(milliseconds: 10), | |
| 311 (_) => log.add('periodic_timer')); | |
| 312 new Timer(new Duration(milliseconds: 10), | |
| 313 () => log.add('timer')); | |
| 314 clockTick(milliseconds: 10); | |
| 315 timer.cancel(); | |
| 316 })(); | |
| 317 expect(log.join(' ')).toEqual('periodic_timer timer'); | |
| 318 | |
| 319 async(() { | |
| 320 clockTick(milliseconds: 10); | |
| 321 })(); | |
| 322 expect(log.join(' ')).toEqual('periodic_timer timer'); | |
| 323 }); | |
| 324 | |
| 325 | |
| 326 it('should throw an error on dangling timers', () { | |
| 327 expect(async(() { | |
| 328 new Timer.periodic(new Duration(milliseconds: 10), | |
| 329 (_) => dump("i never run")); | |
| 330 })).toThrow('1 active timer(s) are still in the queue.'); | |
| 331 }); | |
| 332 }); | |
| 333 }); | |
| 334 }); | |
| OLD | NEW |