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