| 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 unittestTests; | 5 library unittestTests; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 part 'test_utils.dart'; | 8 part 'test_utils.dart'; |
| 9 | 9 |
| 10 doesNotThrow() {} | 10 doesNotThrow() {} |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 shouldPass(0, anything); | 121 shouldPass(0, anything); |
| 122 shouldPass(null, anything); | 122 shouldPass(null, anything); |
| 123 shouldPass(a, anything); | 123 shouldPass(a, anything); |
| 124 shouldFail(a, isNot(anything), "Expected: not anything but: was <{}>."); | 124 shouldFail(a, isNot(anything), "Expected: not anything but: was <{}>."); |
| 125 }); | 125 }); |
| 126 | 126 |
| 127 test('throws', () { | 127 test('throws', () { |
| 128 shouldFail(doesNotThrow, throws, | 128 shouldFail(doesNotThrow, throws, |
| 129 "Expected: throws an exception but: no exception."); | 129 "Expected: throws an exception but: no exception."); |
| 130 shouldPass(doesThrow, throws); | 130 shouldPass(doesThrow, throws); |
| 131 shouldFail(true, throws, |
| 132 "Expected: throws an exception but: not a Function or Future."); |
| 131 }); | 133 }); |
| 132 | 134 |
| 133 test('throwsA', () { | 135 test('throwsA', () { |
| 134 shouldPass(doesThrow, throwsA(equals('X'))); | 136 shouldPass(doesThrow, throwsA(equals('X'))); |
| 135 shouldFail(doesThrow, throwsA(equals('Y')), | 137 shouldFail(doesThrow, throwsA(equals('Y')), |
| 136 "Expected: throws an exception which matches 'Y' " | 138 "Expected: throws an exception which matches 'Y' " |
| 137 "but: exception 'X' does not match 'Y'."); | 139 "but: exception 'X' does not match 'Y'."); |
| 138 }); | 140 }); |
| 139 | 141 |
| 140 test('throwsFormatException', () { | 142 test('throwsFormatException', () { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 shouldFail(b, hasLength(2), | 238 shouldFail(b, hasLength(2), |
| 237 "Expected: an object with length of <2> " | 239 "Expected: an object with length of <2> " |
| 238 "but: was <[0]> with length of <1>."); | 240 "but: was <[0]> with length of <1>."); |
| 239 | 241 |
| 240 b.add(0); | 242 b.add(0); |
| 241 shouldFail(b, hasLength(1), | 243 shouldFail(b, hasLength(1), |
| 242 "Expected: an object with length of <1> " | 244 "Expected: an object with length of <1> " |
| 243 "but: was <[0, 0]> with length of <2>."); | 245 "but: was <[0, 0]> with length of <2>."); |
| 244 shouldPass(b, hasLength(2)); | 246 shouldPass(b, hasLength(2)); |
| 245 }); | 247 }); |
| 248 |
| 249 test('type mismatch', () { |
| 250 var a = new DateTime.utc(2000); |
| 251 var b = a.toString(); |
| 252 shouldFail(a, equals(b), |
| 253 "Expected: '2000-01-01 00:00:00.000Z' " |
| 254 "but: expected String:'2000-01-01 00:00:00.000Z' " |
| 255 "but was DateTime:<2000-01-01 00:00:00.000Z>."); |
| 256 }); |
| 246 }); | 257 }); |
| 247 | 258 |
| 248 group('Numeric Matchers', () { | 259 group('Numeric Matchers', () { |
| 249 | 260 |
| 250 test('greaterThan', () { | 261 test('greaterThan', () { |
| 251 shouldPass(10, greaterThan(9)); | 262 shouldPass(10, greaterThan(9)); |
| 252 shouldFail(9, greaterThan(10), | 263 shouldFail(9, greaterThan(10), |
| 253 "Expected: a value greater than <10> but: was <9>."); | 264 "Expected: a value greater than <10> but: was <9>."); |
| 254 }); | 265 }); |
| 255 | 266 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 var w = new Widget(); | 705 var w = new Widget(); |
| 695 w.price = 10; | 706 w.price = 10; |
| 696 shouldPass(w, new HasPrice(greaterThan(0))); | 707 shouldPass(w, new HasPrice(greaterThan(0))); |
| 697 shouldFail(w, new HasPrice(greaterThan(10)), | 708 shouldFail(w, new HasPrice(greaterThan(10)), |
| 698 'Expected: Widget with a price that is a value greater than <10> ' | 709 'Expected: Widget with a price that is a value greater than <10> ' |
| 699 'but: price was <10>.'); | 710 'but: price was <10>.'); |
| 700 }); | 711 }); |
| 701 }); | 712 }); |
| 702 } | 713 } |
| 703 | 714 |
| OLD | NEW |