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 // Dart test for Splaytrees. | 5 // Dart test for Splaytrees. |
6 library splay_tree_test; | 6 library splay_tree_test; |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 for (int i = 0; i < 3; i++) { | 118 for (int i = 0; i < 3; i++) { |
119 Expect.isTrue(map.containsKey(key(i))); | 119 Expect.isTrue(map.containsKey(key(i))); |
120 Expect.equals(i, map[key(i)]); | 120 Expect.equals(i, map[key(i)]); |
121 } | 121 } |
122 Expect.isFalse(map.containsKey(key(5))); | 122 Expect.isFalse(map.containsKey(key(5))); |
123 Expect.isFalse(map.containsKey(1)); | 123 Expect.isFalse(map.containsKey(1)); |
124 Expect.isFalse(map.containsKey("string")); | 124 Expect.isFalse(map.containsKey("string")); |
125 Expect.equals(null, map[key(5)]); | 125 Expect.equals(null, map[key(5)]); |
126 Expect.equals(null, map[1]); | 126 Expect.equals(null, map[1]); |
127 Expect.equals(null, map["string"]); | 127 Expect.equals(null, map["string"]); |
128 Expect.throws(() { | 128 map[1] = 42; //# 01: compile-time error |
129 map[1] = 42; | 129 map["string"] = 42; //# 02: compile-time error |
130 }); | |
131 Expect.throws(() { | |
132 map["string"] = 42; | |
133 }); | |
134 map[key(5)] = 42; | 130 map[key(5)] = 42; |
135 Expect.equals(4, map.length); | 131 Expect.equals(4, map.length); |
136 Expect.equals(42, map[key(5)]); | 132 Expect.equals(42, map[key(5)]); |
137 } | 133 } |
138 | 134 |
139 class IncomparableKey { | 135 class IncomparableKey { |
140 final int id; | 136 final int id; |
141 IncomparableKey(this.id); | 137 IncomparableKey(this.id); |
142 } | 138 } |
OLD | NEW |