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 test_utils; | 5 library test_utils; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 configureExpectFailureHandler(_testHandler); | 29 configureExpectFailureHandler(_testHandler); |
30 errorCount = 0; | 30 errorCount = 0; |
31 errorString = ''; | 31 errorString = ''; |
32 expect(value, matcher); | 32 expect(value, matcher); |
33 afterTest() { | 33 afterTest() { |
34 configureExpectFailureHandler(null); | 34 configureExpectFailureHandler(null); |
35 expect(errorCount, equals(1)); | 35 expect(errorCount, equals(1)); |
36 if (expected is String) { | 36 if (expected is String) { |
37 expect(errorString, equalsIgnoringWhitespace(expected)); | 37 expect(errorString, equalsIgnoringWhitespace(expected)); |
38 } else { | 38 } else { |
39 expect(errorString.replaceAll('\n', ''), expected); | 39 expect(errorString.replaceAll('\n',''), expected); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 if (isAsync) { | 43 if (isAsync) { |
44 Timer.run(expectAsync(afterTest)); | 44 Timer.run(expectAsync(afterTest)); |
45 } else { | 45 } else { |
46 afterTest(); | 46 afterTest(); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
(...skipping 22 matching lines...) Expand all Loading... |
72 bool matches(item, Map matchState) { | 72 bool matches(item, Map matchState) { |
73 return item is String && | 73 return item is String && |
74 (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix)); | 74 (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix)); |
75 } | 75 } |
76 | 76 |
77 Description describe(Description description) => | 77 Description describe(Description description) => |
78 description.add('a string starting with '). | 78 description.add('a string starting with '). |
79 addDescriptionOf(collapseWhitespace(_prefix)). | 79 addDescriptionOf(collapseWhitespace(_prefix)). |
80 add(' ignoring whitespace'); | 80 add(' ignoring whitespace'); |
81 } | 81 } |
OLD | NEW |