Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: tests/corelib/map_test.dart

Issue 23494027: Make LinkedHashMap also have a factory constructor and be customizable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 map_test; 5 library map_test;
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 void main() { 9 void main() {
10 test(new HashMap()); 10 test(new HashMap());
(...skipping 15 matching lines...) Expand all
26 testWeirdStringKeys(new SplayTreeMap<String, String>()); 26 testWeirdStringKeys(new SplayTreeMap<String, String>());
27 27
28 testNumericKeys(new Map()); 28 testNumericKeys(new Map());
29 testNumericKeys(new Map<num, String>()); 29 testNumericKeys(new Map<num, String>());
30 testNumericKeys(new HashMap()); 30 testNumericKeys(new HashMap());
31 testNumericKeys(new HashMap<num, String>()); 31 testNumericKeys(new HashMap<num, String>());
32 testNumericKeys(new HashMap(equals: identical)); 32 testNumericKeys(new HashMap(equals: identical));
33 testNumericKeys(new HashMap<num, String>(equals: identical)); 33 testNumericKeys(new HashMap<num, String>(equals: identical));
34 testNumericKeys(new LinkedHashMap()); 34 testNumericKeys(new LinkedHashMap());
35 testNumericKeys(new LinkedHashMap<num, String>()); 35 testNumericKeys(new LinkedHashMap<num, String>());
36 testNumericKeys(new LinkedHashMap(equals: identical));
37 testNumericKeys(new LinkedHashMap<num, String>(equals: identical));
36 38
37 testNaNKeys(new Map()); 39 testNaNKeys(new Map());
38 testNaNKeys(new Map<num, String>()); 40 testNaNKeys(new Map<num, String>());
39 testNaNKeys(new HashMap()); 41 testNaNKeys(new HashMap());
40 testNaNKeys(new HashMap<num, String>()); 42 testNaNKeys(new HashMap<num, String>());
41 testNaNKeys(new LinkedHashMap()); 43 testNaNKeys(new LinkedHashMap());
42 testNaNKeys(new LinkedHashMap<num, String>()); 44 testNaNKeys(new LinkedHashMap<num, String>());
43 // Identity maps fail the NaN-keys tests because the test assumes that 45 // Identity maps fail the NaN-keys tests because the test assumes that
44 // NaN is not equal to NaN. 46 // NaN is not equal to NaN.
45 47
46 testIdentityMap(new HashMap(equals: identical)); 48 testIdentityMap(new HashMap(equals: identical));
49 testIdentityMap(new LinkedHashMap(equals: identical));
47 50
48 testCustomMap(new HashMap(equals: myEquals, hashCode: myHashCode)); 51 testCustomMap(new HashMap(equals: myEquals, hashCode: myHashCode));
52 testCustomMap(new LinkedHashMap(equals: myEquals, hashCode: myHashCode));
49 53
50 testIterationOrder(new LinkedHashMap()); 54 testIterationOrder(new LinkedHashMap());
55 testIterationOrder(new LinkedHashMap(equals: identical));
51 } 56 }
52 57
53 58
54 void test(Map map) { 59 void test(Map map) {
55 testDeletedElement(map); 60 testDeletedElement(map);
56 testMap(map, 1, 2, 3, 4, 5, 6, 7, 8); 61 testMap(map, 1, 2, 3, 4, 5, 6, 7, 8);
57 map.clear(); 62 map.clear();
58 testMap(map, "value1", "value2", "value3", "value4", "value5", 63 testMap(map, "value1", "value2", "value3", "value4", "value5",
59 "value6", "value7", "value8"); 64 "value6", "value7", "value8");
60 } 65 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 646
642 int myHashCode(Customer c) => c.secondId; 647 int myHashCode(Customer c) => c.secondId;
643 bool myEquals(Customer a, Customer b) => a.secondId == b.secondId; 648 bool myEquals(Customer a, Customer b) => a.secondId == b.secondId;
644 649
645 testIterationOrder(Map map) { 650 testIterationOrder(Map map) {
646 var order = [0, 6, 4, 2, 7, 9, 7, 1, 2, 5, 3]; 651 var order = [0, 6, 4, 2, 7, 9, 7, 1, 2, 5, 3];
647 for (int i = 0; i < order.length; i++) map[order[i]] = i; 652 for (int i = 0; i < order.length; i++) map[order[i]] = i;
648 Expect.listEquals(map.keys.toList(), [0, 6, 4, 2, 7, 9, 1, 5, 3]); 653 Expect.listEquals(map.keys.toList(), [0, 6, 4, 2, 7, 9, 1, 5, 3]);
649 Expect.listEquals(map.values.toList(), [0, 1, 2, 8, 6, 5, 7, 9, 10]); 654 Expect.listEquals(map.values.toList(), [0, 1, 2, 8, 6, 5, 7, 9, 10]);
650 } 655 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698