| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 callback(); | 244 callback(); |
| 245 }); | 245 }); |
| 246 }); | 246 }); |
| 247 test("fail2", () { | 247 test("fail2", () { |
| 248 return _defer(() { | 248 return _defer(() { |
| 249 fail('failure'); | 249 fail('failure'); |
| 250 }); | 250 }); |
| 251 }); | 251 }); |
| 252 test('foo5', () { | 252 test('foo5', () { |
| 253 }); | 253 }); |
| 254 } else if (testName == 'test returning future using Timer') { | 254 } else if (testName == 'test returning future using runAsync') { |
| 255 test("successful", () { | 255 test("successful", () { |
| 256 return _defer(() { | 256 return _defer(() { |
| 257 Timer.run(() { | 257 runAsync(() { |
| 258 guardAsync(() { | 258 guardAsync(() { |
| 259 expect(true, true); | 259 expect(true, true); |
| 260 }); | 260 }); |
| 261 }); | 261 }); |
| 262 }); | 262 }); |
| 263 }); | 263 }); |
| 264 test("fail1", () { | 264 test("fail1", () { |
| 265 var callback = expectAsync0((){}); | 265 var callback = expectAsync0((){}); |
| 266 return _defer(() { | 266 return _defer(() { |
| 267 Timer.run(() { | 267 runAsync(() { |
| 268 guardAsync(() { | 268 guardAsync(() { |
| 269 expect(true, false); | 269 expect(true, false); |
| 270 callback(); | 270 callback(); |
| 271 }); | 271 }); |
| 272 }); | 272 }); |
| 273 }); | 273 }); |
| 274 }); | 274 }); |
| 275 test('error1', () { | 275 test('error1', () { |
| 276 var callback = expectAsync0((){}); | 276 var callback = expectAsync0((){}); |
| 277 var excesscallback = expectAsync0((){}); | 277 var excesscallback = expectAsync0((){}); |
| 278 return _defer(() { | 278 return _defer(() { |
| 279 Timer.run(() { | 279 runAsync(() { |
| 280 guardAsync(() { | 280 guardAsync(() { |
| 281 excesscallback(); | 281 excesscallback(); |
| 282 excesscallback(); | 282 excesscallback(); |
| 283 callback(); | 283 callback(); |
| 284 }); | 284 }); |
| 285 }); | 285 }); |
| 286 }); | 286 }); |
| 287 }); | 287 }); |
| 288 test("fail2", () { | 288 test("fail2", () { |
| 289 var callback = expectAsync0((){}); | 289 var callback = expectAsync0((){}); |
| 290 return _defer(() { | 290 return _defer(() { |
| 291 Timer.run(() { | 291 runAsync(() { |
| 292 guardAsync(() { | 292 guardAsync(() { |
| 293 fail('failure'); | 293 fail('failure'); |
| 294 callback(); | 294 callback(); |
| 295 }); | 295 }); |
| 296 }); | 296 }); |
| 297 }); | 297 }); |
| 298 }); | 298 }); |
| 299 test('error2', () { | 299 test('error2', () { |
| 300 var callback = expectAsync0((){}); | 300 var callback = expectAsync0((){}); |
| 301 var excesscallback = expectAsync0((){}); | 301 var excesscallback = expectAsync0((){}); |
| 302 return _defer(() { | 302 return _defer(() { |
| 303 Timer.run(() { | 303 runAsync(() { |
| 304 guardAsync(() { | 304 guardAsync(() { |
| 305 excesscallback(); | 305 excesscallback(); |
| 306 excesscallback(); | 306 excesscallback(); |
| 307 excesscallback(); | 307 excesscallback(); |
| 308 callback(); | 308 callback(); |
| 309 }); | 309 }); |
| 310 }); | 310 }); |
| 311 }); | 311 }); |
| 312 }); | 312 }); |
| 313 test('foo6', () { | 313 test('foo6', () { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 'bad setup/bad teardown foo4:bad setup/bad teardown ' | 437 'bad setup/bad teardown foo4:bad setup/bad teardown ' |
| 438 'foo4: Test teardown failed: Failed to complete tearDown:' | 438 'foo4: Test teardown failed: Failed to complete tearDown:' |
| 439 'post groups'), | 439 'post groups'), |
| 440 'test returning future': buildStatusString(2, 4, 0, | 440 'test returning future': buildStatusString(2, 4, 0, |
| 441 'successful::' | 441 'successful::' |
| 442 'error1:Callback called more times than expected (1).:' | 442 'error1:Callback called more times than expected (1).:' |
| 443 'fail1:Expected: <false> but: was <true>.:' | 443 'fail1:Expected: <false> but: was <true>.:' |
| 444 'error2:Callback called more times than expected (1).:' | 444 'error2:Callback called more times than expected (1).:' |
| 445 'fail2:failure:' | 445 'fail2:failure:' |
| 446 'foo5'), | 446 'foo5'), |
| 447 'test returning future using Timer': buildStatusString(2, 4, 0, | 447 'test returning future using runAsync': buildStatusString(2, 4, 0, |
| 448 'successful::' | 448 'successful::' |
| 449 'fail1:Expected: <false> but: was <true>.:' | 449 'fail1:Expected: <false> but: was <true>.:' |
| 450 'error1:Callback called more times than expected (1).:' | 450 'error1:Callback called more times than expected (1).:' |
| 451 'fail2:failure:' | 451 'fail2:failure:' |
| 452 'error2:Callback called more times than expected (1).:' | 452 'error2:Callback called more times than expected (1).:' |
| 453 'foo6'), | 453 'foo6'), |
| 454 'testCases immutable': | 454 'testCases immutable': |
| 455 buildStatusString(1, 0, 0, 'testCases immutable'), | 455 buildStatusString(1, 0, 0, 'testCases immutable'), |
| 456 'runTests without tests': buildStatusString(0, 0, 0, null), | 456 'runTests without tests': buildStatusString(0, 0, 0, null), |
| 457 'nested groups setup/teardown': | 457 'nested groups setup/teardown': |
| (...skipping 12 matching lines...) Expand all Loading... |
| 470 'final') | 470 'final') |
| 471 }; | 471 }; |
| 472 | 472 |
| 473 tests.forEach((String name, String expected) { | 473 tests.forEach((String name, String expected) { |
| 474 test(name, () => spawnFunction(runTest) | 474 test(name, () => spawnFunction(runTest) |
| 475 .call(name) | 475 .call(name) |
| 476 .then((String msg) => expect(msg.trim(), equals(expected)))); | 476 .then((String msg) => expect(msg.trim(), equals(expected)))); |
| 477 }); | 477 }); |
| 478 } | 478 } |
| 479 | 479 |
| OLD | NEW |