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

Unified Diff: tests/corelib/iterable_expand_test.dart

Issue 13877006: Add missing functions to ListMixin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | tests/corelib/list_insert_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/iterable_expand_test.dart
diff --git a/tests/corelib/iterable_expand_test.dart b/tests/corelib/iterable_expand_test.dart
index 5737a9b24cab8305605dcbc02a879f23ab0fe6d1..9c60541f2f41523200972ef83f8ecd1337e06204 100644
--- a/tests/corelib/iterable_expand_test.dart
+++ b/tests/corelib/iterable_expand_test.dart
@@ -3,6 +3,21 @@
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
+import 'dart:collection';
+
+class MyList extends ListBase {
+ List list;
+ MyList(this.list);
+
+ get length => list.length;
+ set length(val) { list.length = val; }
+
+ operator [](index) => list[index];
+ operator []=(index, val) => list[index] = val;
+
+ String toString() => "[" + join(", ") + "]";
+}
+
main() {
test(expectation, iterable) {
@@ -25,6 +40,16 @@ main() {
test([1, 1, 2, 2, 3, 3], [1, 2, 3].expand((x) => [x, x]));
test([1, 1, 2], [1, 2, 3].expand((x) => [x, x, x].skip(x)));
+ test([1], new MyList([1]).expand((x) => [x]));
+ test([1, 2, 3], new MyList([1, 2, 3]).expand((x) => [x]));
+
+ test([], new MyList([1]).expand((x) => []));
+ test([], new MyList([1, 2, 3]).expand((x) => []));
+ test([2], new MyList([1, 2, 3]).expand((x) => x == 2 ? [2] : []));
+
+ test([1, 1, 2, 2, 3, 3], new MyList([1, 2, 3]).expand((x) => [x, x]));
+ test([1, 1, 2], new MyList([1, 2, 3]).expand((x) => [x, x, x].skip(x)));
+
// if function throws, iteration is stopped.
Iterable iterable = [1, 2, 3].expand((x) {
if (x == 2) throw "FAIL";
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | tests/corelib/list_insert_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698