| 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 "dart:collection"; |
| 5 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 6 | 7 |
| 7 testRemove(Collection base) { | 8 testRemove(Collection base) { |
| 8 int length = base.length; | 9 int length = base.length; |
| 9 for (int i = 0; i < length; i++) { | 10 for (int i = 0; i < length; i++) { |
| 10 Expect.isFalse(base.isEmpty); | 11 Expect.isFalse(base.isEmpty); |
| 11 base.remove(base.first); | 12 base.remove(base.first); |
| 12 } | 13 } |
| 13 Expect.isTrue(base.isEmpty); | 14 Expect.isTrue(base.isEmpty); |
| 14 } | 15 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 testRemoveWhere(base.toList(), deltaSet.contains); | 100 testRemoveWhere(base.toList(), deltaSet.contains); |
| 100 testRetainWhere(base.toList(), | 101 testRetainWhere(base.toList(), |
| 101 (e) => !deltaSet.contains(e)); | 102 (e) => !deltaSet.contains(e)); |
| 102 | 103 |
| 103 testRemoveAll(base.toSet(), delta); | 104 testRemoveAll(base.toSet(), delta); |
| 104 testRemoveAll(base.toSet(), deltaSet); | 105 testRemoveAll(base.toSet(), deltaSet); |
| 105 testRetainAll(base.toSet(), delta); | 106 testRetainAll(base.toSet(), delta); |
| 106 testRetainAll(base.toSet(), deltaSet); | 107 testRetainAll(base.toSet(), deltaSet); |
| 107 testRemoveWhere(base.toSet(), deltaSet.contains); | 108 testRemoveWhere(base.toSet(), deltaSet.contains); |
| 108 testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e)); | 109 testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e)); |
| 110 |
| 111 // Test the ListBase class's List implementation. |
| 112 testRemoveAll(new MyList(base.toList()), delta); |
| 113 testRemoveAll(new MyList(base.toList()), deltaSet); |
| 114 testRetainAll(new MyList(base.toList()), delta); |
| 115 testRetainAll(new MyList(base.toList()), deltaSet); |
| 116 testRemoveWhere(new MyList(base.toList()), deltaSet.contains); |
| 117 testRetainWhere(new MyList(base.toList()), |
| 118 (e) => !deltaSet.contains(e)); |
| 119 |
| 109 } | 120 } |
| 110 } | 121 } |
| 111 } | 122 } |
| 112 | 123 |
| 124 class MyList<E> extends ListBase<E> { |
| 125 List<E> _source; |
| 126 MyList(this._source); |
| 127 int get length => _source.length; |
| 128 void set length(int length) { _source.length = length; } |
| 129 E operator[](int index) => _source[index]; |
| 130 void operator[]=(int index, E value) { _source[index] = value; } |
| 131 } |
| OLD | NEW |