| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library unittestTest; | 5 library unittest.returning_future_using_runasync_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | |
| 9 | 8 |
| 9 import 'package:metatest/metatest.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 part 'utils.dart'; | 12 void main() => initTests(_test); |
| 13 | 13 |
| 14 var testName = 'test returning future using scheduleMicrotask'; | 14 void _test(message) { |
| 15 initMetatest(message); |
| 15 | 16 |
| 16 var testFunction = (_) { | 17 expectTestResults('test returning future using scheduleMicrotask', () { |
| 17 test("successful", () { | 18 test("successful", () { |
| 18 return _defer(() { | 19 return new Future.sync(() { |
| 19 scheduleMicrotask(() { | 20 scheduleMicrotask(() { |
| 20 expect(true, true); | 21 expect(true, true); |
| 22 }); |
| 21 }); | 23 }); |
| 22 }); | 24 }); |
| 23 }); | 25 test("fail1", () { |
| 24 test("fail1", () { | 26 var callback = expectAsync(() {}); |
| 25 var callback = expectAsync(() {}); | 27 return new Future.sync(() { |
| 26 return _defer(() { | 28 scheduleMicrotask(() { |
| 27 scheduleMicrotask(() { | 29 expect(true, false); |
| 28 expect(true, false); | 30 callback(); |
| 29 callback(); | 31 }); |
| 30 }); | 32 }); |
| 31 }); | 33 }); |
| 32 }); | 34 test('error1', () { |
| 33 test('error1', () { | 35 var callback = expectAsync(() {}); |
| 34 var callback = expectAsync(() {}); | 36 var excesscallback = expectAsync(() {}); |
| 35 var excesscallback = expectAsync(() {}); | 37 return new Future.sync(() { |
| 36 return _defer(() { | 38 scheduleMicrotask(() { |
| 37 scheduleMicrotask(() { | 39 excesscallback(); |
| 38 excesscallback(); | 40 excesscallback(); |
| 39 excesscallback(); | 41 callback(); |
| 40 callback(); | 42 }); |
| 41 }); | 43 }); |
| 42 }); | 44 }); |
| 43 }); | 45 test("fail2", () { |
| 44 test("fail2", () { | 46 var callback = expectAsync(() {}); |
| 45 var callback = expectAsync(() {}); | 47 return new Future.sync(() { |
| 46 return _defer(() { | 48 scheduleMicrotask(() { |
| 47 scheduleMicrotask(() { | 49 fail('failure'); |
| 48 fail('failure'); | 50 callback(); |
| 49 callback(); | 51 }); |
| 50 }); | 52 }); |
| 51 }); | 53 }); |
| 52 }); | 54 test('error2', () { |
| 53 test('error2', () { | 55 var callback = expectAsync(() {}); |
| 54 var callback = expectAsync(() {}); | 56 var excesscallback = expectAsync(() {}); |
| 55 var excesscallback = expectAsync(() {}); | 57 return new Future.sync(() { |
| 56 return _defer(() { | 58 scheduleMicrotask(() { |
| 57 scheduleMicrotask(() { | 59 excesscallback(); |
| 58 excesscallback(); | 60 excesscallback(); |
| 59 excesscallback(); | 61 excesscallback(); |
| 60 excesscallback(); | 62 callback(); |
| 61 callback(); | 63 }); |
| 62 }); | 64 }); |
| 63 }); | 65 }); |
| 64 }); | 66 test('foo6', () { |
| 65 test('foo6', () { | 67 }); |
| 66 }); | 68 }, [{ |
| 67 }; | 69 'description': 'successful', |
| 68 | 70 'result': 'pass', |
| 69 final expected = buildStatusString(2, 4, 0, | 71 }, { |
| 70 'successful::' | 72 'description': 'fail1', |
| 71 'fail1:Expected: <false> Actual: <true>:' | 73 'message': 'Expected: <false>\n' ' Actual: <true>\n' '', |
| 72 'error1:Callback called more times than expected (1).:' | 74 'result': 'fail', |
| 73 'fail2:failure:' | 75 }, { |
| 74 'error2:Callback called more times than expected (1).:' | 76 'description': 'error1', |
| 75 'foo6'); | 77 'message': 'Callback called more times than expected (1).', |
| 78 'result': 'fail', |
| 79 }, { |
| 80 'description': 'fail2', |
| 81 'message': 'failure', |
| 82 'result': 'fail', |
| 83 }, { |
| 84 'description': 'error2', |
| 85 'message': 'Callback called more times than expected (1).', |
| 86 'result': 'fail', |
| 87 }, { |
| 88 'description': 'foo6', |
| 89 'result': 'pass', |
| 90 }]); |
| 91 } |
| OLD | NEW |