| 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 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 part 'test_utils.dart'; | 9 part 'test_utils.dart'; |
| 10 | 10 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 shouldFail(d, unorderedEquals([1]), | 516 shouldFail(d, unorderedEquals([1]), |
| 517 "Expected: equals <[1]> unordered " | 517 "Expected: equals <[1]> unordered " |
| 518 "but: has too many elements (2 > 1)."); | 518 "but: has too many elements (2 > 1)."); |
| 519 shouldFail(d, unorderedEquals([3, 2, 1]), | 519 shouldFail(d, unorderedEquals([3, 2, 1]), |
| 520 "Expected: equals <[3, 2, 1]> unordered " | 520 "Expected: equals <[3, 2, 1]> unordered " |
| 521 "but: has too few elements (2 < 3)."); | 521 "but: has too few elements (2 < 3)."); |
| 522 shouldFail(d, unorderedEquals([3, 1]), | 522 shouldFail(d, unorderedEquals([3, 1]), |
| 523 "Expected: equals <[3, 1]> unordered " | 523 "Expected: equals <[3, 1]> unordered " |
| 524 "but: has no match for element <3> at position 0."); | 524 "but: has no match for element <3> at position 0."); |
| 525 }); | 525 }); |
| 526 |
| 527 test('pairwise compare', () { |
| 528 var c = [1, 2]; |
| 529 var d = [1, 2, 3]; |
| 530 var e = [1, 4, 9]; |
| 531 shouldFail('x', pairwiseCompare(e, (e,a) => a <= e, |
| 532 "less than or equal"), |
| 533 "Expected: pairwise less than or equal <[1, 4, 9]> but: " |
| 534 "not an Iterable."); |
| 535 shouldFail(c, pairwiseCompare(e, (e,a) => a <= e, "less than or equal"), |
| 536 "Expected: pairwise less than or equal <[1, 4, 9]> but: " |
| 537 "length was 2 instead of 3."); |
| 538 shouldPass(d, pairwiseCompare(e, (e,a) => a <= e, "less than or equal")); |
| 539 shouldFail(d, pairwiseCompare(e, (e,a) => a < e, "less than"), |
| 540 "Expected: pairwise less than <[1, 4, 9]> but: " |
| 541 "<1> not less than <1> at position 0."); |
| 542 shouldPass(d, pairwiseCompare(e, (e,a) => a * a == e, "square root of")); |
| 543 shouldFail(d, pairwiseCompare(e, (e,a) => a + a == e, "double"), |
| 544 "Expected: pairwise double <[1, 4, 9]> but: " |
| 545 "<1> not double <1> at position 0."); |
| 546 }); |
| 526 }); | 547 }); |
| 527 | 548 |
| 528 group('Map Matchers', () { | 549 group('Map Matchers', () { |
| 529 | 550 |
| 530 test('isEmpty', () { | 551 test('isEmpty', () { |
| 531 var a = new Map(); | 552 var a = new Map(); |
| 532 shouldPass({}, isEmpty); | 553 shouldPass({}, isEmpty); |
| 533 shouldPass(a, isEmpty); | 554 shouldPass(a, isEmpty); |
| 534 a['foo'] = 'bar'; | 555 a['foo'] = 'bar'; |
| 535 shouldFail(a, isEmpty, "Expected: empty but: was <{foo: bar}>."); | 556 shouldFail(a, isEmpty, "Expected: empty but: was <{foo: bar}>."); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 w.price = 10; | 730 w.price = 10; |
| 710 shouldPass(w, new HasPrice(10)); | 731 shouldPass(w, new HasPrice(10)); |
| 711 shouldPass(w, new HasPrice(greaterThan(0))); | 732 shouldPass(w, new HasPrice(greaterThan(0))); |
| 712 shouldFail(w, new HasPrice(greaterThan(10)), | 733 shouldFail(w, new HasPrice(greaterThan(10)), |
| 713 'Expected: Widget with a price that is a value greater than <10> ' | 734 'Expected: Widget with a price that is a value greater than <10> ' |
| 714 'but: price was <10>.'); | 735 'but: price was <10>.'); |
| 715 }); | 736 }); |
| 716 }); | 737 }); |
| 717 } | 738 } |
| 718 | 739 |
| OLD | NEW |