OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // TODO(gram): | 5 // TODO(gram): |
6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. | 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. |
7 // insufficient callbacks, because the timeout is controlled externally | 7 // insufficient callbacks, because the timeout is controlled externally |
8 // (test.dart?), and we would need to use a shorter timeout for the inner tests | 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests |
9 // so the outer timeout doesn't fire. So I removed all such tests. | 9 // so the outer timeout doesn't fire. So I removed all such tests. |
10 // I'd like to revisit this at some point. | 10 // I'd like to revisit this at some point. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 group('a', () { | 101 group('a', () { |
102 setUp(() { _testconfig.setup = 'setup'; }); | 102 setUp(() { _testconfig.setup = 'setup'; }); |
103 tearDown(() { _testconfig.teardown = 'teardown'; }); | 103 tearDown(() { _testconfig.teardown = 'teardown'; }); |
104 test(testName, () {}); | 104 test(testName, () {}); |
105 }); | 105 }); |
106 } else if (testName == 'correct callback test') { | 106 } else if (testName == 'correct callback test') { |
107 test(testName, | 107 test(testName, |
108 () =>_defer(expectAsync0((){ ++_testconfig.count;}))); | 108 () =>_defer(expectAsync0((){ ++_testconfig.count;}))); |
109 } else if (testName == 'excess callback test') { | 109 } else if (testName == 'excess callback test') { |
110 test(testName, () { | 110 test(testName, () { |
111 var _callback = expectAsync0(() => ++_testconfig.count); | 111 var _callback0 = expectAsync0(() => ++_testconfig.count); |
112 _defer(_callback); | 112 var _callback1 = expectAsync0(() => ++_testconfig.count); |
113 _defer(_callback); | 113 var _callback2 = expectAsync0(() { |
| 114 _callback1(); |
| 115 _callback1(); |
| 116 _callback0(); |
| 117 }); |
| 118 _defer(_callback2); |
114 }); | 119 }); |
115 } else if (testName == 'completion test') { | 120 } else if (testName == 'completion test') { |
116 test(testName, () { | 121 test(testName, () { |
117 var _callback; | 122 var _callback; |
118 _callback = expectAsyncUntil0(() { | 123 _callback = expectAsyncUntil0(() { |
119 if (++_testconfig.count < 10) { | 124 if (++_testconfig.count < 10) { |
120 _defer(_callback); | 125 _defer(_callback); |
121 } | 126 } |
122 }, | 127 }, |
123 () => (_testconfig.count == 10)); | 128 () => (_testconfig.count == 10)); |
124 _defer(_callback); | 129 _defer(_callback); |
125 }); | 130 }); |
126 } else if (testName == 'async exception test') { | 131 } else if (testName == 'async exception test') { |
127 test(testName, () { | 132 test(testName, () { |
128 expectAsync0(() {}); | 133 expectAsync0(() {}); |
129 _defer(() => guardAsync(() { throw "error!"; })); | 134 _defer(() => guardAsync(() { throw "error!"; })); |
130 }); | 135 }); |
131 } else if (testName == 'late exception test') { | 136 } else if (testName == 'late exception test') { |
| 137 var f; |
132 test('testOne', () { | 138 test('testOne', () { |
133 var f = expectAsync0(() {}); | 139 f = expectAsync0(() {}); |
134 _defer(protectAsync0(() { | 140 _defer(f); |
135 _defer(protectAsync0(() => fail('first failure'))); | |
136 fail('second failure'); | |
137 })); | |
138 }); | 141 }); |
139 test('testTwo', () { | 142 test('testTwo', () { |
140 _defer(expectAsync0(() {})); | 143 _defer(expectAsync0(() { f(); })); |
141 }); | 144 }); |
142 } else if (testName == 'middle exception test') { | 145 } else if (testName == 'middle exception test') { |
143 test('testOne', () { expect(true, isTrue); }); | 146 test('testOne', () { expect(true, isTrue); }); |
144 test('testTwo', () { expect(true, isFalse); }); | 147 test('testTwo', () { expect(true, isFalse); }); |
145 test('testThree', () { | 148 test('testThree', () { |
146 var done = expectAsync0((){}); | 149 var done = expectAsync0((){}); |
147 _defer(() { | 150 _defer(() { |
148 expect(true, isTrue); | 151 expect(true, isTrue); |
149 done(); | 152 done(); |
150 }); | 153 }); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 }); | 292 }); |
290 }); | 293 }); |
291 test('error1', () { | 294 test('error1', () { |
292 var callback = expectAsync0((){}); | 295 var callback = expectAsync0((){}); |
293 var excesscallback = expectAsync0((){}); | 296 var excesscallback = expectAsync0((){}); |
294 return _defer(() { | 297 return _defer(() { |
295 Timer.run(() { | 298 Timer.run(() { |
296 guardAsync(() { | 299 guardAsync(() { |
297 excesscallback(); | 300 excesscallback(); |
298 excesscallback(); | 301 excesscallback(); |
299 excesscallback(); | |
300 callback(); | 302 callback(); |
301 }); | 303 }); |
302 }); | 304 }); |
303 }); | 305 }); |
304 }); | 306 }); |
305 test("fail2", () { | 307 test("fail2", () { |
306 var callback = expectAsync0((){}); | 308 var callback = expectAsync0((){}); |
307 return _defer(() { | 309 return _defer(() { |
308 Timer.run(() { | 310 Timer.run(() { |
309 guardAsync(() { | 311 guardAsync(() { |
310 fail('failure'); | 312 fail('failure'); |
311 callback(); | 313 callback(); |
312 }); | 314 }); |
313 }); | 315 }); |
314 }); | 316 }); |
315 }); | 317 }); |
316 test('error2', () { | 318 test('error2', () { |
317 var callback = expectAsync0((){}); | 319 var callback = expectAsync0((){}); |
318 var excesscallback = expectAsync0((){}); | 320 var excesscallback = expectAsync0((){}); |
319 return _defer(() { | 321 return _defer(() { |
320 Timer.run(() { | 322 Timer.run(() { |
321 guardAsync(() { | 323 guardAsync(() { |
322 excesscallback(); | 324 excesscallback(); |
323 excesscallback(); | 325 excesscallback(); |
| 326 excesscallback(); |
324 callback(); | 327 callback(); |
325 }); | 328 }); |
326 }); | 329 }); |
327 }); | 330 }); |
328 }); | 331 }); |
329 test('foo6', () { | 332 test('foo6', () { |
330 }); | 333 }); |
331 } | 334 } |
332 }); | 335 }); |
333 } | 336 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 buildStatusString(0, 1, 0, tests[1], | 374 buildStatusString(0, 1, 0, tests[1], |
372 message: 'Expected: <5> but: was <4>.'), | 375 message: 'Expected: <5> but: was <4>.'), |
373 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), | 376 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), |
374 buildStatusString(2, 0, 0, 'a a::a b b'), | 377 buildStatusString(2, 0, 0, 'a a::a b b'), |
375 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'), | 378 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'), |
376 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '', | 379 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '', |
377 teardown: 'teardown'), | 380 teardown: 'teardown'), |
378 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0, | 381 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0, |
379 setup: 'setup', teardown: 'teardown'), | 382 setup: 'setup', teardown: 'teardown'), |
380 buildStatusString(1, 0, 0, tests[7], count: 1), | 383 buildStatusString(1, 0, 0, tests[7], count: 1), |
381 buildStatusString(0, 0, 1, tests[8], count: 1, | 384 buildStatusString(0, 1, 0, tests[8], count: 1, |
382 message: 'Callback called more times than expected (2 > 1).'), | 385 message: 'Callback called more times than expected (1).'), |
383 buildStatusString(1, 0, 0, tests[9], count: 10), | 386 buildStatusString(1, 0, 0, tests[9], count: 10), |
384 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), | 387 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), |
385 buildStatusString(1, 0, 1, 'testOne', | 388 buildStatusString(1, 0, 1, 'testOne', |
386 message: 'Callback called after already being marked as done ' | 389 message: 'Callback called after test case testOne has already ' |
387 '(1).:testTwo:'), | 390 'been marked as done.:testTwo:'), |
388 buildStatusString(2, 1, 0, | 391 buildStatusString(2, 1, 0, |
389 'testOne::testTwo:Expected: false but: was <true>.:testThree'), | 392 'testOne::testTwo:Expected: false but: was <true>.:testThree'), |
390 buildStatusString(2, 0, 3, | 393 buildStatusString(2, 0, 3, |
391 'good setup/good teardown foo1::' | 394 'good setup/good teardown foo1::' |
392 'good setup/bad teardown foo2:good setup/bad teardown ' | 395 'good setup/bad teardown foo2:good setup/bad teardown ' |
393 'foo2: Test teardown failed: Failed to complete tearDown:' | 396 'foo2: Test teardown failed: Failed to complete tearDown:' |
394 'bad setup/good teardown foo3:bad setup/good teardown ' | 397 'bad setup/good teardown foo3:bad setup/good teardown ' |
395 'foo3: Test setup failed: Failed to complete setUp:' | 398 'foo3: Test setup failed: Failed to complete setUp:' |
396 'bad setup/bad teardown foo4:bad setup/bad teardown ' | 399 'bad setup/bad teardown foo4:bad setup/bad teardown ' |
397 'foo4: Test teardown failed: Failed to complete tearDown:' | 400 'foo4: Test teardown failed: Failed to complete tearDown:' |
398 'post groups'), | 401 'post groups'), |
399 buildStatusString(2, 2, 2, | 402 buildStatusString(2, 4, 0, |
400 'successful::' | 403 'successful::' |
401 'error1:Callback called more times than expected (3 > 1).:' | 404 'error1:Callback called more times than expected (1).:' |
402 'fail1:Expected: <false> but: was <true>.:' | 405 'fail1:Expected: <false> but: was <true>.:' |
403 'error2:Callback called more times than expected (2 > 1).:' | 406 'error2:Callback called more times than expected (1).:' |
404 'fail2:failure:' | 407 'fail2:failure:' |
405 'foo5'), | 408 'foo5'), |
406 buildStatusString(2, 2, 2, | 409 buildStatusString(2, 4, 0, |
407 'successful::' | 410 'successful::' |
408 'fail1:Expected: <false> but: was <true>.:' | 411 'fail1:Expected: <false> but: was <true>.:' |
409 'error1:Callback called more times than expected (3 > 1).:' | 412 'error1:Callback called more times than expected (1).:' |
410 'fail2:failure:' | 413 'fail2:failure:' |
411 'error2:Callback called more times than expected (2 > 1).:' | 414 'error2:Callback called more times than expected (1).:' |
412 'foo6'), | 415 'foo6'), |
413 ]; | 416 ]; |
414 | 417 |
415 actual = []; | 418 actual = []; |
416 | 419 |
417 nextTest(0); | 420 nextTest(0); |
418 } | 421 } |
419 | 422 |
OLD | NEW |