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

Unified Diff: tests/corelib/list_test.dart

Issue 315173005: Add "last" setter to List. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: tests/corelib/list_test.dart
diff --git a/tests/corelib/list_test.dart b/tests/corelib/list_test.dart
index 5187ee84ccce4cb210548b52923e1db406914798..e8756a2e2c9b6846c82b90d722d2e4cb64015cf4 100644
--- a/tests/corelib/list_test.dart
+++ b/tests/corelib/list_test.dart
@@ -45,6 +45,12 @@ void main() {
testTypedGrowableList(new Uint32List(0).toList());
testTypedGrowableList(new Int32List(0).toList());
+ // Lists based on ListBase and ListMixin.
+ testGrowableList(new BaseList());
+ testGrowableList(new BaseList().toList());
+ testGrowableList(new MixinList());
+ testGrowableList(new MixinList().toList());
+
testListConstructor();
}
@@ -70,6 +76,23 @@ void testTypedLengthInvariantOperations(List list) {
list[i] = i;
}
+ // last=
+ Expect.listEquals([0, 1, 2, 3], list);
+ list.last = 47;
+ Expect.listEquals([0, 1, 2, 47], list);
+ list.last -= 5;
+ Expect.listEquals([0, 1, 2, 42], list);
+ list.last++;
+ Expect.listEquals([0, 1, 2, 43], list);
+ ++list.last;
+ Expect.listEquals([0, 1, 2, 44], list);
+ list.last--;
+ Expect.listEquals([0, 1, 2, 43], list);
+ --list.last;
+ Expect.listEquals([0, 1, 2, 42], list);
+ list.last = 3;
+ Expect.listEquals([0, 1, 2, 3], list);
+
// indexOf, lastIndexOf
for (int i = 0; i < 4; i++) {
Expect.equals(i, list[i]);
@@ -504,3 +527,15 @@ void testListConstructor() {
Expect.throws(() { new List.filled(-2, 42); }); // Not negative.
Expect.throws(() { new List.filled(null, 42); }); // Not null.
}
+
+abstract class ListImpl<E>{
+ List _base = [];
+ int get length => _base.length;
+ void set length(int length) { _base.length = length; }
+ E operator[](int index) => _base[index];
+ void operator[]=(int index, E value) { _base[index] = value; }
+}
+
+class BaseList<E> = ListBase<E> with ListImpl<E>;
+
+class MixinList<E> = ListImpl<E> with ListMixin<E>;

Powered by Google App Engine
This is Rietveld 408576698