OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 matcher.core_matchers_test; | 5 library matcher.core_matchers_test; |
6 | 6 |
7 import 'package:matcher/matcher.dart'; | 7 import 'package:matcher/matcher.dart'; |
8 import 'package:unittest/unittest.dart' show test, group; | 8 import 'package:unittest/unittest.dart' show test, group; |
9 | 9 |
10 import 'test_utils.dart'; | 10 import 'test_utils.dart'; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 test('returnsNormally', () { | 86 test('returnsNormally', () { |
87 shouldPass(doesNotThrow, returnsNormally); | 87 shouldPass(doesNotThrow, returnsNormally); |
88 shouldFail(doesThrow, returnsNormally, | 88 shouldFail(doesThrow, returnsNormally, |
89 matches( | 89 matches( |
90 r"Expected: return normally" | 90 r"Expected: return normally" |
91 r" Actual: <Closure(: \(\) => dynamic " | 91 r" Actual: <Closure(: \(\) => dynamic " |
92 r"from Function 'doesThrow': static\.)?>" | 92 r"from Function 'doesThrow': static\.)?>" |
93 r" Which: threw 'X'")); | 93 r" Which: threw 'X'")); |
94 }); | 94 }); |
95 | 95 |
96 | |
97 test('hasLength', () { | 96 test('hasLength', () { |
98 var a = new Map(); | 97 var a = new Map(); |
99 var b = new List(); | 98 var b = new List(); |
100 shouldPass(a, hasLength(0)); | 99 shouldPass(a, hasLength(0)); |
101 shouldPass(b, hasLength(0)); | 100 shouldPass(b, hasLength(0)); |
102 shouldPass('a', hasLength(1)); | 101 shouldPass('a', hasLength(1)); |
103 shouldFail(0, hasLength(0), new PrefixMatcher( | 102 shouldFail(0, hasLength(0), new PrefixMatcher( |
104 "Expected: an object with length of <0> " | 103 "Expected: an object with length of <0> " |
105 "Actual: <0> " | 104 "Actual: <0> " |
106 "Which: has no length property")); | 105 "Which: has no length property")); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 }); | 170 }); |
172 | 171 |
173 group('Predicate Matchers', () { | 172 group('Predicate Matchers', () { |
174 test('isInstanceOf', () { | 173 test('isInstanceOf', () { |
175 shouldFail(0, predicate((x) => x is String, "an instance of String"), | 174 shouldFail(0, predicate((x) => x is String, "an instance of String"), |
176 "Expected: an instance of String Actual: <0>"); | 175 "Expected: an instance of String Actual: <0>"); |
177 shouldPass('cow', predicate((x) => x is String, "an instance of String")); | 176 shouldPass('cow', predicate((x) => x is String, "an instance of String")); |
178 }); | 177 }); |
179 }); | 178 }); |
180 } | 179 } |
OLD | NEW |