Index: pkg/unittest/test/matchers_test.dart |
diff --git a/pkg/unittest/test/matchers_test.dart b/pkg/unittest/test/matchers_test.dart |
index d1d998a7f53078bdeb6fd4fe567f5743dc99da40..c95bfa18c163983b819dfc2ecb15ccfa3eec2156 100644 |
--- a/pkg/unittest/test/matchers_test.dart |
+++ b/pkg/unittest/test/matchers_test.dart |
@@ -4,6 +4,7 @@ |
library unittestTests; |
import 'package:unittest/unittest.dart'; |
+import 'dart:async'; |
part 'test_utils.dart'; |
doesNotThrow() {} |
@@ -514,6 +515,67 @@ void main() { |
}); |
}); |
+ group('Future Matchers', () { |
+ |
+ test('completes - unexpected error', () { |
+ var completer = new Completer(); |
+ completer.completeError('X'); |
+ shouldFail(completer.future, completes, |
+ contains('Expected future to complete successfully, ' |
+ 'but it failed with X'), |
+ isAsync: true); |
+ }); |
+ |
+ test('completes - successfully', () { |
+ var completer = new Completer(); |
+ completer.complete('1'); |
+ shouldPass(completer.future, completes, isAsync: true); |
+ }); |
+ |
+ test('throws - unexpected to see normal completion', () { |
+ var completer = new Completer(); |
+ completer.complete('1'); |
+ shouldFail(completer.future, throws, |
+ contains("Expected future to fail, but succeeded with '1'"), |
+ isAsync: true); |
+ }); |
+ |
+ test('throws - expected to see exception', () { |
+ var completer = new Completer(); |
+ completer.completeError('X'); |
+ shouldPass(completer.future, throws, isAsync: true); |
+ }); |
+ |
+ test('throws - expected to see exception thrown later on', () { |
+ var completer = new Completer(); |
+ var chained = completer.future.then((_) { throw 'X'; }); |
+ shouldPass(chained, throws, isAsync: true); |
+ completer.complete('1'); |
+ }); |
+ |
+ test('throwsA - unexpected normal completion', () { |
+ var completer = new Completer(); |
+ completer.complete('1'); |
+ shouldFail(completer.future, throwsA(equals('X')), |
+ contains("Expected future to fail, but succeeded with '1'"), |
+ isAsync: true); |
+ }); |
+ |
+ test('throwsA - correct error', () { |
+ var completer = new Completer(); |
+ completer.completeError('X'); |
+ shouldPass(completer.future, throwsA(equals('X')), isAsync: true); |
+ }); |
+ |
+ test('throwsA - wrong error', () { |
+ var completer = new Completer(); |
+ completer.completeError('X'); |
+ shouldFail(completer.future, throwsA(equals('Y')), |
+ "Expected: 'Y' but: was 'X'.", |
+ isAsync: true); |
+ }); |
+ }); |
+ |
group('Predicate Matchers', () { |
test('isInstanceOf', () { |
shouldFail(0, predicate((x) => x is String, "an instance of String"), |