| 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.excess_callback_test; |
| 6 | |
| 7 import 'dart:async'; | |
| 8 import 'dart:isolate'; | |
| 9 | 6 |
| 10 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 11 | 8 |
| 12 part 'utils.dart'; | 9 import 'package:metatest/metatest.dart'; |
| 13 | 10 |
| 14 var testName = 'excess callback test'; | 11 void main() => initTests(_test); |
| 15 | 12 |
| 16 var testFunction = (TestConfiguration testConfig) { | 13 void _test(message) { |
| 17 test(testName, () { | 14 initMetatest(message); |
| 18 var _callback0 = expectAsync(() => ++testConfig.count); | 15 |
| 19 var _callback1 = expectAsync(() => ++testConfig.count); | 16 var count = 0; |
| 20 var _callback2 = expectAsync(() { | 17 |
| 21 _callback1(); | 18 expectTestResults('excess callback test', () { |
| 22 _callback1(); | 19 test('test', () { |
| 23 _callback0(); | 20 var _callback0 = expectAsync(() => ++count); |
| 21 var _callback1 = expectAsync(() => ++count); |
| 22 var _callback2 = expectAsync(() { |
| 23 _callback1(); |
| 24 _callback1(); |
| 25 _callback0(); |
| 26 }); |
| 27 defer(_callback2); |
| 24 }); | 28 }); |
| 25 _defer(_callback2); | |
| 26 }); | |
| 27 }; | |
| 28 | 29 |
| 29 var expected = buildStatusString(0, 1, 0, testName, | 30 test('verify count', () { |
| 30 count: 1, message: 'Callback called more times than expected (1).'); | 31 expect(count, 1); |
| 32 }); |
| 33 }, [{ |
| 34 'description': 'test', |
| 35 'message': 'Callback called more times than expected (1).', |
| 36 'result': 'fail' |
| 37 }, { |
| 38 'description': 'verify count', |
| 39 'result': 'pass', |
| 40 }]); |
| 41 } |
| OLD | NEW |