| 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 part of unittestTests; |
| 6 | 6 |
| 7 int errorCount; | 7 int errorCount; |
| 8 String errorString; | 8 String errorString; |
| 9 var _testHandler = null; | 9 var _testHandler = null; |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 configureExpectFailureHandler(_testHandler); | 25 configureExpectFailureHandler(_testHandler); |
| 26 errorCount = 0; | 26 errorCount = 0; |
| 27 errorString = ''; | 27 errorString = ''; |
| 28 expect(value, matcher); | 28 expect(value, matcher); |
| 29 afterTest() { | 29 afterTest() { |
| 30 configureExpectFailureHandler(null); | 30 configureExpectFailureHandler(null); |
| 31 expect(errorCount, equals(1)); | 31 expect(errorCount, equals(1)); |
| 32 if (expected is String) { | 32 if (expected is String) { |
| 33 expect(errorString, equalsIgnoringWhitespace(expected)); | 33 expect(errorString, equalsIgnoringWhitespace(expected)); |
| 34 } else { | 34 } else { |
| 35 expect(errorString, expected); | 35 expect(errorString.replaceAll('\n',''), expected); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 if (isAsync) { | 39 if (isAsync) { |
| 40 Timer.run(expectAsync0(afterTest)); | 40 Timer.run(expectAsync0(afterTest)); |
| 41 } else { | 41 } else { |
| 42 afterTest(); | 42 afterTest(); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 void shouldPass(value, Matcher matcher, {bool isAsync: false}) { | 46 void shouldPass(value, Matcher matcher, {bool isAsync: false}) { |
| 47 configureExpectFailureHandler(_testHandler); | 47 configureExpectFailureHandler(_testHandler); |
| 48 errorCount = 0; | 48 errorCount = 0; |
| 49 errorString = ''; | 49 errorString = ''; |
| 50 expect(value, matcher); | 50 expect(value, matcher); |
| 51 afterTest() { | 51 afterTest() { |
| 52 configureExpectFailureHandler(null); | 52 configureExpectFailureHandler(null); |
| 53 expect(errorCount, equals(0)); | 53 expect(errorCount, equals(0)); |
| 54 } | 54 } |
| 55 if (isAsync) { | 55 if (isAsync) { |
| 56 Timer.run(expectAsync0(afterTest)); | 56 Timer.run(expectAsync0(afterTest)); |
| 57 } else { | 57 } else { |
| 58 afterTest(); | 58 afterTest(); |
| 59 } | 59 } |
| 60 } | 60 } |
| OLD | NEW |