Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tests/corelib/collection_removes_test.dart

Issue 14048002: Make the analyzer happy about collections. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/core/list.dart ('k') | tests/corelib/list_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/core/list.dart ('k') | tests/corelib/list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698