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 part 'test_utils.dart'; | 9 part 'test_utils.dart'; |
9 | 10 |
10 doesNotThrow() {} | 11 doesNotThrow() {} |
11 doesThrow() { throw 'X'; } | 12 doesThrow() { throw 'X'; } |
12 | 13 |
13 class PrefixMatcher extends BaseMatcher { | 14 class PrefixMatcher extends BaseMatcher { |
14 final String _prefix; | 15 final String _prefix; |
15 const PrefixMatcher(this._prefix); | 16 const PrefixMatcher(this._prefix); |
16 bool matches(item, MatchState matchState) { | 17 bool matches(item, MatchState matchState) { |
17 return item is String && | 18 return item is String && |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 var b = new Map(); | 536 var b = new Map(); |
536 b['foo'] = 'bar'; | 537 b['foo'] = 'bar'; |
537 var c = new Map(); | 538 var c = new Map(); |
538 c['bar'] = 'foo'; | 539 c['bar'] = 'foo'; |
539 shouldPass(a, equals(b)); | 540 shouldPass(a, equals(b)); |
540 shouldFail(b, equals(c), | 541 shouldFail(b, equals(c), |
541 "Expected: <{bar: foo}> but: missing map key 'bar'."); | 542 "Expected: <{bar: foo}> but: missing map key 'bar'."); |
542 }); | 543 }); |
543 | 544 |
544 test('equals with different lengths', () { | 545 test('equals with different lengths', () { |
545 var a = new Map(); | 546 var a = new LinkedHashMap(); |
546 a['foo'] = 'bar'; | 547 a['foo'] = 'bar'; |
547 var b = new Map(); | 548 var b = new LinkedHashMap(); |
548 b['foo'] = 'bar'; | 549 b['foo'] = 'bar'; |
549 b['bar'] = 'foo'; | 550 b['bar'] = 'foo'; |
550 var c = new Map(); | 551 var c = new LinkedHashMap(); |
551 c['bar'] = 'foo'; | 552 c['bar'] = 'foo'; |
552 c['barrista'] = 'caffeine'; | 553 c['barrista'] = 'caffeine'; |
553 shouldFail(a, equals(b), | 554 shouldFail(a, equals(b), |
554 "Expected: <{bar: foo, foo: bar}> " | 555 "Expected: <{foo: bar, bar: foo}> " |
555 "but: different map lengths; missing map key 'bar'."); | 556 "but: different map lengths; missing map key 'bar'."); |
556 shouldFail(b, equals(a), | 557 shouldFail(b, equals(a), |
557 "Expected: <{foo: bar}> " | 558 "Expected: <{foo: bar}> " |
558 "but: different map lengths; extra map key 'bar'."); | 559 "but: different map lengths; extra map key 'bar'."); |
559 shouldFail(b, equals(c), | 560 shouldFail(b, equals(c), |
560 "Expected: <{bar: foo, barrista: caffeine}> " | 561 "Expected: <{bar: foo, barrista: caffeine}> " |
561 "but: missing map key 'barrista'."); | 562 "but: missing map key 'barrista'."); |
562 shouldFail(c, equals(b), | 563 shouldFail(c, equals(b), |
563 "Expected: <{bar: foo, foo: bar}> " | 564 "Expected: <{foo: bar, bar: foo}> " |
564 "but: missing map key 'foo'."); | 565 "but: missing map key 'foo'."); |
565 shouldFail(a, equals(c), | 566 shouldFail(a, equals(c), |
566 "Expected: <{bar: foo, barrista: caffeine}> " | 567 "Expected: <{bar: foo, barrista: caffeine}> " |
567 "but: different map lengths; missing map key 'bar'."); | 568 "but: different map lengths; missing map key 'bar'."); |
568 shouldFail(c, equals(a), | 569 shouldFail(c, equals(a), |
569 "Expected: <{foo: bar}> " | 570 "Expected: <{foo: bar}> " |
570 "but: different map lengths; missing map key 'foo'."); | 571 "but: different map lengths; missing map key 'foo'."); |
571 }); | 572 }); |
572 | 573 |
573 test('contains', () { | 574 test('contains', () { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 var w = new Widget(); | 703 var w = new Widget(); |
703 w.price = 10; | 704 w.price = 10; |
704 shouldPass(w, new HasPrice(greaterThan(0))); | 705 shouldPass(w, new HasPrice(greaterThan(0))); |
705 shouldFail(w, new HasPrice(greaterThan(10)), | 706 shouldFail(w, new HasPrice(greaterThan(10)), |
706 'Expected: Widget with a price that is a value greater than <10> ' | 707 'Expected: Widget with a price that is a value greater than <10> ' |
707 'but: price was <10>.'); | 708 'but: price was <10>.'); |
708 }); | 709 }); |
709 }); | 710 }); |
710 } | 711 } |
711 | 712 |
OLD | NEW |