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

Side by Side Diff: pkg/unittest/test/unittest_test.dart

Issue 12366004: When we have excess callbacks, throw instead of calling error() so that we (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }); 289 });
290 }); 290 });
291 test('error1', () { 291 test('error1', () {
292 var callback = expectAsync0((){}); 292 var callback = expectAsync0((){});
293 var excesscallback = expectAsync0((){}); 293 var excesscallback = expectAsync0((){});
294 return _defer(() { 294 return _defer(() {
295 Timer.run(() { 295 Timer.run(() {
296 guardAsync(() { 296 guardAsync(() {
297 excesscallback(); 297 excesscallback();
298 excesscallback(); 298 excesscallback();
299 excesscallback();
300 callback(); 299 callback();
301 }); 300 });
302 }); 301 });
303 }); 302 });
304 }); 303 });
305 test("fail2", () { 304 test("fail2", () {
306 var callback = expectAsync0((){}); 305 var callback = expectAsync0((){});
307 return _defer(() { 306 return _defer(() {
308 Timer.run(() { 307 Timer.run(() {
309 guardAsync(() { 308 guardAsync(() {
310 fail('failure'); 309 fail('failure');
311 callback(); 310 callback();
312 }); 311 });
313 }); 312 });
314 }); 313 });
315 }); 314 });
316 test('error2', () { 315 test('error2', () {
317 var callback = expectAsync0((){}); 316 var callback = expectAsync0((){});
318 var excesscallback = expectAsync0((){}); 317 var excesscallback = expectAsync0((){});
319 return _defer(() { 318 return _defer(() {
320 Timer.run(() { 319 Timer.run(() {
321 guardAsync(() { 320 guardAsync(() {
322 excesscallback(); 321 excesscallback();
323 excesscallback(); 322 excesscallback();
323 excesscallback();
324 callback(); 324 callback();
325 }); 325 });
326 }); 326 });
327 }); 327 });
328 }); 328 });
329 test('foo6', () { 329 test('foo6', () {
330 }); 330 });
331 } 331 }
332 }); 332 });
333 } 333 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 buildStatusString(0, 1, 0, tests[1], 371 buildStatusString(0, 1, 0, tests[1],
372 message: 'Expected: <5> but: was <4>.'), 372 message: 'Expected: <5> but: was <4>.'),
373 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), 373 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'),
374 buildStatusString(2, 0, 0, 'a a::a b b'), 374 buildStatusString(2, 0, 0, 'a a::a b b'),
375 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'), 375 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'),
376 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '', 376 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '',
377 teardown: 'teardown'), 377 teardown: 'teardown'),
378 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0, 378 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0,
379 setup: 'setup', teardown: 'teardown'), 379 setup: 'setup', teardown: 'teardown'),
380 buildStatusString(1, 0, 0, tests[7], count: 1), 380 buildStatusString(1, 0, 0, tests[7], count: 1),
381 buildStatusString(0, 0, 1, tests[8], count: 1, 381 buildStatusString(0, 1, 0, tests[8], count: 1,
382 message: 'Callback called more times than expected (2 > 1).'), 382 message: 'Callback called more times than expected (2 > 1).'),
383 buildStatusString(1, 0, 0, tests[9], count: 10), 383 buildStatusString(1, 0, 0, tests[9], count: 10),
384 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), 384 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'),
385 buildStatusString(1, 0, 1, 'testOne', 385 buildStatusString(1, 0, 1, 'testOne',
386 message: 'Callback called after already being marked as done ' 386 message: 'Callback called after already being marked as done '
387 '(1).:testTwo:'), 387 '(1).:testTwo:'),
388 buildStatusString(2, 1, 0, 388 buildStatusString(2, 1, 0,
389 'testOne::testTwo:Expected: false but: was <true>.:testThree'), 389 'testOne::testTwo:Expected: false but: was <true>.:testThree'),
390 buildStatusString(2, 0, 3, 390 buildStatusString(2, 0, 3,
391 'good setup/good teardown foo1::' 391 'good setup/good teardown foo1::'
392 'good setup/bad teardown foo2:good setup/bad teardown ' 392 'good setup/bad teardown foo2:good setup/bad teardown '
393 'foo2: Test teardown failed: Failed to complete tearDown:' 393 'foo2: Test teardown failed: Failed to complete tearDown:'
394 'bad setup/good teardown foo3:bad setup/good teardown ' 394 'bad setup/good teardown foo3:bad setup/good teardown '
395 'foo3: Test setup failed: Failed to complete setUp:' 395 'foo3: Test setup failed: Failed to complete setUp:'
396 'bad setup/bad teardown foo4:bad setup/bad teardown ' 396 'bad setup/bad teardown foo4:bad setup/bad teardown '
397 'foo4: Test teardown failed: Failed to complete tearDown:' 397 'foo4: Test teardown failed: Failed to complete tearDown:'
398 'post groups'), 398 'post groups'),
399 buildStatusString(2, 2, 2, 399 buildStatusString(2, 3, 1,
400 'successful::' 400 'successful::'
401 'error1:Callback called more times than expected (3 > 1).:' 401 'error1:Caught Callback called more times than expected (3 > 1).:'
402 'fail1:Expected: <false> but: was <true>.:' 402 'fail1:Expected: <false> but: was <true>.:'
403 'error2:Callback called more times than expected (2 > 1).:' 403 'error2:Callback called more times than expected (2 > 1).:'
404 'fail2:failure:' 404 'fail2:failure:'
405 'foo5'), 405 'foo5'),
406 buildStatusString(2, 2, 2, 406 buildStatusString(2, 3, 1,
407 'successful::' 407 'successful::'
408 'fail1:Expected: <false> but: was <true>.:' 408 'fail1:Expected: <false> but: was <true>.:'
409 'error1:Callback called more times than expected (3 > 1).:' 409 'error1:Callback called more times than expected (2 > 1).:'
410 'fail2:failure:' 410 'fail2:failure:'
411 'error2:Callback called more times than expected (2 > 1).:' 411 'error2:Caught Callback called more times than expected (3 > 1).:'
412 'foo6'), 412 'foo6'),
413 ]; 413 ];
414 414
415 actual = []; 415 actual = [];
416 416
417 nextTest(0); 417 nextTest(0);
418 } 418 }
419 419
OLDNEW
« pkg/unittest/lib/unittest.dart ('K') | « pkg/unittest/lib/unittest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698