OLD | NEW |
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 import 'dart:convert' show JSON; | 8 import 'dart:convert' show JSON; |
9 | 9 |
10 Map newJsonMap() | 10 Map newJsonMap() |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 int index = _keys.indexOf(key); | 896 int index = _keys.indexOf(key); |
897 if (index < 0) return null; | 897 if (index < 0) return null; |
898 return _values[index]; | 898 return _values[index]; |
899 } | 899 } |
900 | 900 |
901 Iterable<K> get keys => _keys.skip(0); | 901 Iterable<K> get keys => _keys.skip(0); |
902 } | 902 } |
903 | 903 |
904 abstract class Super implements Comparable {} | 904 abstract class Super implements Comparable {} |
905 abstract class Interface implements Comparable {} | 905 abstract class Interface implements Comparable {} |
906 class Sub extends Super implements Interface, Comparable<Sub> { | 906 class Sub extends Super implements Interface, Comparable { |
907 int compareTo(Sub other) => 0; | 907 int compareTo(Sub other) => 0; |
908 int get hashCode => 0; | 908 int get hashCode => 0; |
909 bool operator==(Object other) => other is Sub; | 909 bool operator==(other) => other is Sub; |
910 } | 910 } |
911 | 911 |
912 expectMap(Map expect, Map actual) { | 912 expectMap(Map expect, Map actual) { |
913 Expect.equals(expect.length, actual.length, "length"); | 913 Expect.equals(expect.length, actual.length, "length"); |
914 for (var key in expect.keys) { | 914 for (var key in expect.keys) { |
915 Expect.isTrue(actual.containsKey(key), "containsKey $key"); | 915 Expect.isTrue(actual.containsKey(key), "containsKey $key"); |
916 Expect.equals(expect[key], actual[key]); | 916 Expect.equals(expect[key], actual[key]); |
917 } | 917 } |
918 } | 918 } |
919 | 919 |
(...skipping 22 matching lines...) Expand all Loading... |
942 Map<Interface, Interface> interfaceMap = <Interface, Interface>{sub: sub}; | 942 Map<Interface, Interface> interfaceMap = <Interface, Interface>{sub: sub}; |
943 expectMap(superMap, new Map<Super, Super>.from(interfaceMap)); | 943 expectMap(superMap, new Map<Super, Super>.from(interfaceMap)); |
944 expectMap(superMap, new Map<Interface, Interface>.from(superMap)); | 944 expectMap(superMap, new Map<Interface, Interface>.from(superMap)); |
945 expectMap(superMap, new HashMap<Super, Super>.from(interfaceMap)); | 945 expectMap(superMap, new HashMap<Super, Super>.from(interfaceMap)); |
946 expectMap(superMap, new HashMap<Interface, Interface>.from(superMap)); | 946 expectMap(superMap, new HashMap<Interface, Interface>.from(superMap)); |
947 expectMap(superMap, new LinkedHashMap<Super, Super>.from(interfaceMap)); | 947 expectMap(superMap, new LinkedHashMap<Super, Super>.from(interfaceMap)); |
948 expectMap(superMap, new LinkedHashMap<Interface, Interface>.from(superMap)); | 948 expectMap(superMap, new LinkedHashMap<Interface, Interface>.from(superMap)); |
949 expectMap(superMap, new SplayTreeMap<Super, Super>.from(interfaceMap)); | 949 expectMap(superMap, new SplayTreeMap<Super, Super>.from(interfaceMap)); |
950 expectMap(superMap, new SplayTreeMap<Interface, Interface>.from(superMap)); | 950 expectMap(superMap, new SplayTreeMap<Interface, Interface>.from(superMap)); |
951 } | 951 } |
OLD | NEW |