| 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('unittestTest'); | 5 #library('unittestTest'); |
| 6 | 6 |
| 7 #import('../../lib/unittest/unittest.dart'); | 7 #import('../../lib/unittest/unittest.dart'); |
| 8 | 8 |
| 9 | 9 |
| 10 doesNotThrow() {} | 10 doesNotThrow() {} |
| 11 doesThrow() { throw 'X'; } | 11 doesThrow() { throw 'X'; } |
| 12 | 12 |
| 13 int errorCount; | 13 int errorCount; |
| 14 String errorString; | 14 String errorString; |
| 15 var testHandler; | 15 var testHandler; |
| 16 | 16 |
| 17 class MyFailureHandler extends DefaultFailureHandler { | 17 class MyFailureHandler extends DefaultFailureHandler { |
| 18 void fail(String reason) { | 18 void fail(String reason) { |
| 19 ++errorCount; | 19 ++errorCount; |
| 20 errorString = reason; | 20 errorString = reason; |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 void shouldFail(var value, Matcher matcher, String expected) { | 24 void shouldFail(var value, Matcher matcher, expected) { |
| 25 errorCount = 0; | 25 errorCount = 0; |
| 26 errorString = ''; | 26 errorString = ''; |
| 27 configureExpectHandler(testHandler); | 27 configureExpectHandler(testHandler); |
| 28 expect(value, matcher); | 28 expect(value, matcher); |
| 29 configureExpectHandler(null); | 29 configureExpectHandler(null); |
| 30 expect(errorCount, equals(1)); | 30 expect(errorCount, equals(1)); |
| 31 if (expected is String) | 31 if (expected is String) |
| 32 expect(errorString, equalsIgnoringWhitespace(expected)); | 32 expect(errorString, equalsIgnoringWhitespace(expected)); |
| 33 else | 33 else |
| 34 expect(errorString, expected); | 34 expect(errorString, expected); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 test('allOf', () { | 444 test('allOf', () { |
| 445 shouldPass(1, allOf([lessThan(10), greaterThan(0)])); | 445 shouldPass(1, allOf([lessThan(10), greaterThan(0)])); |
| 446 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]), | 446 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]), |
| 447 "Expected: (a value less than <10> and a value greater than <0>) " | 447 "Expected: (a value less than <10> and a value greater than <0>) " |
| 448 "but: a value greater than <0> was <-1>"); | 448 "but: a value greater than <0> was <-1>"); |
| 449 }); | 449 }); |
| 450 }); | 450 }); |
| 451 } | 451 } |
| 452 | 452 |
| 453 | 453 |
| OLD | NEW |