| 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 part of unittestTests; | 5 library test_utils; |
| 6 |
| 7 import 'package:unittest/unittest.dart'; |
| 8 |
| 9 import 'dart:async'; |
| 6 | 10 |
| 7 int errorCount; | 11 int errorCount; |
| 8 String errorString; | 12 String errorString; |
| 9 var _testHandler = null; | 13 var _testHandler = null; |
| 10 | 14 |
| 11 class MyFailureHandler extends DefaultFailureHandler { | 15 class MyFailureHandler extends DefaultFailureHandler { |
| 12 void fail(String reason) { | 16 void fail(String reason) { |
| 13 ++errorCount; | 17 ++errorCount; |
| 14 errorString = reason; | 18 errorString = reason; |
| 15 } | 19 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 afterTest() { | 55 afterTest() { |
| 52 configureExpectFailureHandler(null); | 56 configureExpectFailureHandler(null); |
| 53 expect(errorCount, equals(0)); | 57 expect(errorCount, equals(0)); |
| 54 } | 58 } |
| 55 if (isAsync) { | 59 if (isAsync) { |
| 56 Timer.run(expectAsync0(afterTest)); | 60 Timer.run(expectAsync0(afterTest)); |
| 57 } else { | 61 } else { |
| 58 afterTest(); | 62 afterTest(); |
| 59 } | 63 } |
| 60 } | 64 } |
| 65 |
| 66 doesNotThrow() {} |
| 67 doesThrow() { throw 'X'; } |
| 68 |
| 69 class PrefixMatcher extends BaseMatcher { |
| 70 final String _prefix; |
| 71 const PrefixMatcher(this._prefix); |
| 72 bool matches(item, MatchState matchState) { |
| 73 return item is String && |
| 74 (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix)); |
| 75 } |
| 76 |
| 77 Description describe(Description description) => |
| 78 description.add('a string starting with '). |
| 79 addDescriptionOf(collapseWhitespace(_prefix)). |
| 80 add(' ignoring whitespace'); |
| 81 } |
| OLD | NEW |