| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 | 7 |
| 8 main() { | 8 main() { |
| 9 defaultFunctionValuesTest(); | 9 defaultFunctionValuesTest(); |
| 10 defaultKeyFunctionTest(); | 10 defaultKeyFunctionTest(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 Expect.throws(() { | 139 Expect.throws(() { |
| 140 new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3], | 140 new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3], |
| 141 // No "key" map, defaults to identity, which returns int, not String. | 141 // No "key" map, defaults to identity, which returns int, not String. |
| 142 value: value | 142 value: value |
| 143 ); | 143 ); |
| 144 }); | 144 }); |
| 145 | 145 |
| 146 Expect.throws(() { | 146 Expect.throws(() { |
| 147 new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3], | 147 new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3], |
| 148 key: id, // wrong type. | 148 key: id, // wrong type. |
| 149 value: value | 149 value: value |
| 150 ); | 150 ); |
| 151 }); | 151 }); |
| 152 | 152 |
| 153 Expect.throws(() { | 153 Expect.throws(() { |
| 154 new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3], | 154 new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3], |
| 155 key: key, | 155 key: key, |
| 156 value: id // wrong type. | 156 value: id // wrong type. |
| 157 ); | 157 ); |
| 158 }); | 158 }); |
| 159 | 159 |
| 160 // But it works with explicit types when used correctly. | 160 // But it works with explicit types when used correctly. |
| 161 SplayTreeMap<String, bool> map = | 161 SplayTreeMap<String, bool> map = |
| 162 new SplayTreeMap<String, bool>.fromIterable(<int>[1, 2, 3], | 162 new SplayTreeMap<String, bool>.fromIterable(<int>[1, 2, 3], |
| 163 key: key, | 163 key: key, |
| 164 value: value); | 164 value: value); |
| 165 Iterable<String> keys = map.keys; | 165 Iterable<String> keys = map.keys; |
| 166 Iterable<bool> values = map.values; | 166 Iterable<bool> values = map.values; |
| 167 List<String> keyList = keys.toList(); | 167 List<String> keyList = keys.toList(); |
| 168 List<bool> valueList = values.toList(); | 168 List<bool> valueList = values.toList(); |
| 169 Expect.equals(3, keyList.length); | 169 Expect.equals(3, keyList.length); |
| 170 Expect.equals(3, valueList.length); | 170 Expect.equals(3, valueList.length); |
| 171 Expect.equals(keys.first, map.firstKey()); | 171 Expect.equals(keys.first, map.firstKey()); |
| 172 Expect.equals(keys.last, map.lastKey()); | 172 Expect.equals(keys.last, map.lastKey()); |
| 173 } | 173 } |
| OLD | NEW |