OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 'dart:collection'; | 5 import 'dart:collection'; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class MyEntry extends LinkedListEntry<MyEntry> { | 8 class MyEntry extends LinkedListEntry<MyEntry> { |
9 final int value; | 9 final int value; |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 var list1 = new LinkedList<MyEntry>(); | 117 var list1 = new LinkedList<MyEntry>(); |
118 list1.addFirst(new MyEntry(0)); | 118 list1.addFirst(new MyEntry(0)); |
119 | 119 |
120 var list2 = new LinkedList<MyEntry>(); | 120 var list2 = new LinkedList<MyEntry>(); |
121 Expect.throws(() => list2.addFirst(list1.first)); | 121 Expect.throws(() => list2.addFirst(list1.first)); |
122 | 122 |
123 Expect.throws(() => new MyEntry(0).unlink()); | 123 Expect.throws(() => new MyEntry(0).unlink()); |
124 } | 124 } |
125 | 125 |
126 testConcurrentModificationError() { | 126 testConcurrentModificationError() { |
127 test(function(LinkedList ll)) { | 127 test(function(LinkedList<MyEntry> ll)) { |
128 var ll = new LinkedList<MyEntry>(); | 128 var ll = new LinkedList<MyEntry>(); |
129 for (int i = 0; i < 10; i++) { | 129 for (int i = 0; i < 10; i++) { |
130 ll.add(new MyEntry(i)); | 130 ll.add(new MyEntry(i)); |
131 } | 131 } |
132 Expect.throws(() => function(ll), (e) => e is ConcurrentModificationError); | 132 Expect.throws(() => function(ll), (e) => e is ConcurrentModificationError); |
133 } | 133 } |
134 | 134 |
135 test((ll) { | 135 test((ll) { |
136 for (var x in ll) { | 136 for (var x in ll) { |
137 ll.remove(x); | 137 ll.remove(x); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 }); | 219 }); |
220 }); | 220 }); |
221 } | 221 } |
222 | 222 |
223 main() { | 223 main() { |
224 testInsert(); | 224 testInsert(); |
225 testRemove(); | 225 testRemove(); |
226 testBadAdd(); | 226 testBadAdd(); |
227 testConcurrentModificationError(); | 227 testConcurrentModificationError(); |
228 } | 228 } |
OLD | NEW |