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 unittestTest; |
6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 | 9 |
10 part 'unittest_test_utils.dart'; | 10 part 'unittest_test_utils.dart'; |
11 | 11 |
12 var testFunction = (_) { | 12 var testFunction = (_) { |
13 test('protectAsync0', () { | 13 test('protectAsync0', () { |
14 var protected = () { | 14 var protected = protectAsync0(() { |
15 throw new StateError('error during protectAsync0'); | 15 throw new StateError('error during protectAsync0'); |
16 }; | 16 }); |
17 new Future(protected); | 17 new Future(protected); |
18 }); | 18 }); |
19 | 19 |
20 test('protectAsync1', () { | 20 test('protectAsync1', () { |
21 var protected = (arg) { | 21 var protected = protectAsync1((arg) { |
22 throw new StateError('error during protectAsync1: $arg'); | 22 throw new StateError('error during protectAsync1: $arg'); |
23 }; | 23 }); |
24 new Future(() => protected('one arg')); | 24 new Future(() => protected('one arg')); |
25 }); | 25 }); |
26 | 26 |
27 test('protectAsync2', () { | 27 test('protectAsync2', () { |
28 var protected = (arg1, arg2) { | 28 var protected = protectAsync2((arg1, arg2) { |
29 throw new StateError('error during protectAsync2: $arg1, $arg2'); | 29 throw new StateError('error during protectAsync2: $arg1, $arg2'); |
30 }; | 30 }); |
31 new Future(() => protected('arg1', 'arg2')); | 31 new Future(() => protected('arg1', 'arg2')); |
32 }); | 32 }); |
33 | 33 |
34 test('throw away 1', () { | 34 test('throw away 1', () { |
35 return new Future(() {}); | 35 return new Future(() {}); |
36 }); | 36 }); |
37 }; | 37 }; |
38 | 38 |
39 var expected = '1:0:3:4:0:::null:' | 39 var expected = '1:0:3:4:0:::null:' |
40 'protectAsync0:Caught Bad state: error during protectAsync0:' | 40 'protectAsync0:Caught Bad state: error during protectAsync0:' |
41 'protectAsync1:Caught Bad state: error during protectAsync1: one arg:' | 41 'protectAsync1:Caught Bad state: error during protectAsync1: one arg:' |
42 'protectAsync2:Caught Bad state: error during protectAsync2: arg1, arg2:' | 42 'protectAsync2:Caught Bad state: error during protectAsync2: arg1, arg2:' |
43 'throw away 1:'; | 43 'throw away 1:'; |
OLD | NEW |