| 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.test_utils; | 5 library matcher.test_utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:matcher/matcher.dart'; | 9 import 'package:matcher/matcher.dart'; |
| 10 import 'package:unittest/unittest.dart' show test, expectAsync; | 10 import 'package:unittest/unittest.dart' show test, expectAsync; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 expect(_errorCount, equals(0)); | 58 expect(_errorCount, equals(0)); |
| 59 } | 59 } |
| 60 if (isAsync) { | 60 if (isAsync) { |
| 61 Timer.run(expectAsync(afterTest)); | 61 Timer.run(expectAsync(afterTest)); |
| 62 } else { | 62 } else { |
| 63 afterTest(); | 63 afterTest(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 doesNotThrow() {} | 67 doesNotThrow() {} |
| 68 doesThrow() { throw 'X'; } | 68 doesThrow() { |
| 69 throw 'X'; |
| 70 } |
| 69 | 71 |
| 70 class PrefixMatcher extends Matcher { | 72 class PrefixMatcher extends Matcher { |
| 71 final String _prefix; | 73 final String _prefix; |
| 72 const PrefixMatcher(this._prefix); | 74 const PrefixMatcher(this._prefix); |
| 73 bool matches(item, Map matchState) { | 75 bool matches(item, Map matchState) { |
| 74 return item is String && | 76 return item is String && |
| 75 (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix)); | 77 (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 Description describe(Description description) => | 80 Description describe(Description description) => description |
| 79 description.add('a string starting with '). | 81 .add('a string starting with ') |
| 80 addDescriptionOf(collapseWhitespace(_prefix)). | 82 .addDescriptionOf(collapseWhitespace(_prefix)) |
| 81 add(' ignoring whitespace'); | 83 .add(' ignoring whitespace'); |
| 82 } | 84 } |
| OLD | NEW |