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.protect_async_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:isolate'; | |
9 | 8 |
10 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
11 | 10 |
12 part 'utils.dart'; | 11 import 'package:metatest/metatest.dart'; |
13 | 12 |
14 var testFunction = (_) { | 13 void main() => initTests(_test); |
15 test('protectAsync0', () { | |
16 var protected = () { | |
17 throw new StateError('error during protectAsync0'); | |
18 }; | |
19 new Future(protected); | |
20 }); | |
21 | 14 |
22 test('protectAsync1', () { | 15 void _test(message) { |
23 var protected = (arg) { | 16 initMetatest(message); |
24 throw new StateError('error during protectAsync1: $arg'); | |
25 }; | |
26 new Future(() => protected('one arg')); | |
27 }); | |
28 | 17 |
29 test('protectAsync2', () { | 18 expectTestResults('protectAsync', () { |
30 var protected = (arg1, arg2) { | 19 test('protectAsync0', () { |
31 throw new StateError('error during protectAsync2: $arg1, $arg2'); | 20 var protected = () { |
32 }; | 21 throw new StateError('error during protectAsync0'); |
33 new Future(() => protected('arg1', 'arg2')); | 22 }; |
34 }); | 23 new Future(protected); |
| 24 }); |
35 | 25 |
36 test('throw away 1', () { | 26 test('protectAsync1', () { |
37 return new Future(() {}); | 27 var protected = (arg) { |
38 }); | 28 throw new StateError('error during protectAsync1: $arg'); |
39 }; | 29 }; |
| 30 new Future(() => protected('one arg')); |
| 31 }); |
40 | 32 |
41 var expected = '1:0:3:4:0:::null:' | 33 test('protectAsync2', () { |
42 'protectAsync0:Caught Bad state: error during protectAsync0:' | 34 var protected = (arg1, arg2) { |
43 'protectAsync1:Caught Bad state: error during protectAsync1: one arg:' | 35 throw new StateError('error during protectAsync2: $arg1, $arg2'); |
44 'protectAsync2:Caught Bad state: error during protectAsync2: arg1, arg2:' | 36 }; |
45 'throw away 1:'; | 37 new Future(() => protected('arg1', 'arg2')); |
| 38 }); |
| 39 |
| 40 test('throw away 1', () { |
| 41 return new Future(() {}); |
| 42 }); |
| 43 }, [{ |
| 44 'result': 'error', |
| 45 'message': 'Caught Bad state: error during protectAsync0' |
| 46 }, { |
| 47 'result': 'error', |
| 48 'message': 'Caught Bad state: error during protectAsync1: one arg' |
| 49 }, { |
| 50 'result': 'error', |
| 51 'message': 'Caught Bad state: error during protectAsync2: arg1, arg2' |
| 52 }, { |
| 53 'result': 'pass', |
| 54 'message': '' |
| 55 }]); |
| 56 } |
OLD | NEW |