| 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 group('Map Matchers', () { | 514 group('Map Matchers', () { |
| 515 | 515 |
| 516 test('isEmpty', () { | 516 test('isEmpty', () { |
| 517 var a = new Map(); | 517 var a = new Map(); |
| 518 shouldPass({}, isEmpty); | 518 shouldPass({}, isEmpty); |
| 519 shouldPass(a, isEmpty); | 519 shouldPass(a, isEmpty); |
| 520 a['foo'] = 'bar'; | 520 a['foo'] = 'bar'; |
| 521 shouldFail(a, isEmpty, "Expected: empty but: was <{foo: bar}>."); | 521 shouldFail(a, isEmpty, "Expected: empty but: was <{foo: bar}>."); |
| 522 }); | 522 }); |
| 523 | 523 |
| 524 test('equals', () { |
| 525 var a = new Map(); |
| 526 a['foo'] = 'bar'; |
| 527 var b = new Map(); |
| 528 b['foo'] = 'bar'; |
| 529 var c = new Map(); |
| 530 c['bar'] = 'foo'; |
| 531 shouldPass(a, equals(b)); |
| 532 shouldFail(b, equals(c), |
| 533 "Expected: <{bar: foo}> but: missing map key 'bar'."); |
| 534 }); |
| 535 |
| 536 test('equals with different lengths', () { |
| 537 var a = new Map(); |
| 538 a['foo'] = 'bar'; |
| 539 var b = new Map(); |
| 540 b['foo'] = 'bar'; |
| 541 b['bar'] = 'foo'; |
| 542 var c = new Map(); |
| 543 c['bar'] = 'foo'; |
| 544 c['barrista'] = 'caffeine'; |
| 545 shouldFail(a, equals(b), |
| 546 "Expected: <{bar: foo, foo: bar}> " |
| 547 "but: different map lengths; missing map key 'bar'."); |
| 548 shouldFail(b, equals(a), |
| 549 "Expected: <{foo: bar}> " |
| 550 "but: different map lengths; extra map key 'bar'."); |
| 551 shouldFail(b, equals(c), |
| 552 "Expected: <{bar: foo, barrista: caffeine}> " |
| 553 "but: missing map key 'barrista'."); |
| 554 shouldFail(c, equals(b), |
| 555 "Expected: <{bar: foo, foo: bar}> " |
| 556 "but: missing map key 'foo'."); |
| 557 shouldFail(a, equals(c), |
| 558 "Expected: <{bar: foo, barrista: caffeine}> " |
| 559 "but: different map lengths; missing map key 'bar'."); |
| 560 shouldFail(c, equals(a), |
| 561 "Expected: <{foo: bar}> " |
| 562 "but: different map lengths; missing map key 'foo'."); |
| 563 }); |
| 564 |
| 524 test('contains', () { | 565 test('contains', () { |
| 525 var a = new Map(); | 566 var a = new Map(); |
| 526 a['foo'] = 'bar'; | 567 a['foo'] = 'bar'; |
| 527 var b = new Map(); | 568 var b = new Map(); |
| 528 shouldPass(a, contains('foo')); | 569 shouldPass(a, contains('foo')); |
| 529 shouldFail(b, contains('foo'), | 570 shouldFail(b, contains('foo'), |
| 530 "Expected: contains 'foo' but: was <{}>."); | 571 "Expected: contains 'foo' but: was <{}>."); |
| 531 shouldFail(10, contains('foo'), | 572 shouldFail(10, contains('foo'), |
| 532 "Expected: contains 'foo' but: was <10>."); | 573 "Expected: contains 'foo' but: was <10>."); |
| 533 }); | 574 }); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 var w = new Widget(); | 694 var w = new Widget(); |
| 654 w.price = 10; | 695 w.price = 10; |
| 655 shouldPass(w, new HasPrice(greaterThan(0))); | 696 shouldPass(w, new HasPrice(greaterThan(0))); |
| 656 shouldFail(w, new HasPrice(greaterThan(10)), | 697 shouldFail(w, new HasPrice(greaterThan(10)), |
| 657 'Expected: Widget with a price that is a value greater than <10> ' | 698 'Expected: Widget with a price that is a value greater than <10> ' |
| 658 'but: price was <10>.'); | 699 'but: price was <10>.'); |
| 659 }); | 700 }); |
| 660 }); | 701 }); |
| 661 } | 702 } |
| 662 | 703 |
| OLD | NEW |