OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library unittestTest; |
| 6 import 'dart:isolate'; |
| 7 import 'dart:async'; |
| 8 import 'package:unittest/unittest.dart'; |
| 9 |
| 10 part 'unittest_test_utils.dart'; |
| 11 |
| 12 var testFunction = (TestConfiguration testConfig) { |
| 13 test('expectAsync zero params', () { |
| 14 _defer(expectAsync(() { |
| 15 ++testConfig.count; |
| 16 })); |
| 17 }); |
| 18 |
| 19 test('expectAsync 1 param', () { |
| 20 var func = expectAsync((arg) { |
| 21 expect(arg, 0); |
| 22 ++testConfig.count; |
| 23 }); |
| 24 _defer(() => func(0)); |
| 25 }); |
| 26 |
| 27 test('expectAsync 2 param', () { |
| 28 var func = expectAsync((arg0, arg1) { |
| 29 expect(arg0, 0); |
| 30 expect(arg1, 1); |
| 31 ++testConfig.count; |
| 32 }); |
| 33 _defer(() => func(0, 1)); |
| 34 }); |
| 35 |
| 36 test('single arg to Future.catchError', () { |
| 37 var func = expectAsync((error) { |
| 38 expect(error, isStateError); |
| 39 ++testConfig.count; |
| 40 }); |
| 41 |
| 42 new Future(() { |
| 43 throw new StateError('test'); |
| 44 }).catchError(func); |
| 45 }); |
| 46 |
| 47 test('2 args to Future.catchError', () { |
| 48 var func = expectAsync((error, stack) { |
| 49 expect(error, isStateError); |
| 50 expect(stack is StackTrace, isTrue); |
| 51 ++testConfig.count; |
| 52 }); |
| 53 |
| 54 new Future(() { |
| 55 throw new StateError('test'); |
| 56 }).catchError(func); |
| 57 }); |
| 58 |
| 59 test('zero of two optional positional args', () { |
| 60 var func = expectAsync(([arg0 = true, arg1 = true]) { |
| 61 expect(arg0, isTrue); |
| 62 expect(arg1, isTrue); |
| 63 ++testConfig.count; |
| 64 }); |
| 65 |
| 66 _defer(() => func()); |
| 67 }); |
| 68 |
| 69 test('one of two optional positional args', () { |
| 70 var func = expectAsync(([arg0 = true, arg1 = true]) { |
| 71 expect(arg0, isFalse); |
| 72 expect(arg1, isTrue); |
| 73 ++testConfig.count; |
| 74 }); |
| 75 |
| 76 _defer(() => func(false)); |
| 77 }); |
| 78 |
| 79 test('two of two optional positional args', () { |
| 80 var func = expectAsync(([arg0 = true, arg1 = true]) { |
| 81 expect(arg0, isFalse); |
| 82 expect(arg1, isNull); |
| 83 ++testConfig.count; |
| 84 }); |
| 85 |
| 86 _defer(() => func(false, null)); |
| 87 }); |
| 88 }; |
| 89 |
| 90 final expected = '8:0:0:8:8:::null:expectAsync zero params:' |
| 91 ':expectAsync 1 param::expectAsync 2 param:' |
| 92 ':single arg to Future.catchError::2 args to Future.catchError:' |
| 93 ':zero of two optional positional args:' |
| 94 ':one of two optional positional args:' |
| 95 ':two of two optional positional args:'; |
OLD | NEW |