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

Side by Side Diff: pkg/collection/test/iterable_zip_test.dart

Issue 118783004: Add missing files from previous commit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « pkg/collection/lib/iterable_zip.dart ('k') | pkg/polymer/lib/src/build/runner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:collection";
6 import "package:collection/iterable_zip.dart";
7 import "package:unittest/unittest.dart";
8
9 /// Iterable like [base] except that it throws when value equals [errorValue].
10 Iterable iterError(Iterable base, int errorValue) {
11 return base.map((x) => x == errorValue ? throw "BAD" : x);
12 }
13
14 main() {
15 test("Basic", () {
16 expect(new IterableZip([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
17 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
18 });
19
20 test("Uneven length 1", () {
21 expect(new IterableZip([[1, 2, 3, 99, 100], [4, 5, 6], [7, 8, 9]]),
22 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
23 });
24
25 test("Uneven length 2", () {
26 expect(new IterableZip([[1, 2, 3], [4, 5, 6, 99, 100], [7, 8, 9]]),
27 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
28 });
29
30 test("Uneven length 3", () {
31 expect(new IterableZip([[1, 2, 3], [4, 5, 6], [7, 8, 9, 99, 100]]),
32 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
33 });
34
35 test("Uneven length 3", () {
36 expect(new IterableZip([[1, 2, 3, 98], [4, 5, 6], [7, 8, 9, 99, 100]]),
37 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
38 });
39
40 test("Empty 1", () {
41 expect(new IterableZip([[], [4, 5, 6], [7, 8, 9]]), equals([]));
42 });
43
44 test("Empty 2", () {
45 expect(new IterableZip([[1, 2, 3], [], [7, 8, 9]]), equals([]));
46 });
47
48 test("Empty 3", () {
49 expect(new IterableZip([[1, 2, 3], [4, 5, 6], []]), equals([]));
50 });
51
52 test("Empty source", () {
53 expect(new IterableZip([]), equals([]));
54 });
55
56 test("Single Source", () {
57 expect(new IterableZip([[1, 2, 3]]), equals([[1], [2], [3]]));
58 });
59
60 test("Not-lists", () {
61 // Use other iterables than list literals.
62 Iterable it1 = [1, 2, 3, 4, 5, 6].where((x) => x < 4);
63 Set it2 = new LinkedHashSet()..add(4)..add(5)..add(6);
64 Iterable it3 = (new LinkedHashMap()..[7] = 0 ..[8] = 0 ..[9] = 0).keys;
65 Iterable<Iterable> allIts =
66 new Iterable.generate(3, (i) => [it1, it2, it3][i]);
67 expect(new IterableZip(allIts),
68 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
69 });
70
71 test("Error 1", () {
72 expect(() => new IterableZip([iterError([1, 2, 3], 2),
73 [4, 5, 6],
74 [7, 8, 9]]).toList(),
75 throwsA(equals("BAD")));
76 });
77
78 test("Error 2", () {
79 expect(() => new IterableZip([[1, 2, 3],
80 iterError([4, 5, 6], 5),
81 [7, 8, 9]]).toList(),
82 throwsA(equals("BAD")));
83 });
84
85 test("Error 3", () {
86 expect(() => new IterableZip([[1, 2, 3],
87 [4, 5, 6],
88 iterError([7, 8, 9], 8)]).toList(),
89 throwsA(equals("BAD")));
90 });
91
92 test("Error at end", () {
93 expect(() => new IterableZip([[1, 2, 3],
94 iterError([4, 5, 6], 6),
95 [7, 8, 9]]).toList(),
96 throwsA(equals("BAD")));
97 });
98
99 test("Error before first end", () {
100 expect(() => new IterableZip([iterError([1, 2, 3, 4], 4),
101 [4, 5, 6],
102 [7, 8, 9]]).toList(),
103 throwsA(equals("BAD")));
104 });
105
106 test("Error after first end", () {
107 expect(new IterableZip([[1, 2, 3],
108 [4, 5, 6],
109 iterError([7, 8, 9, 10], 10)]),
110 equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
111 });
112 }
OLDNEW
« no previous file with comments | « pkg/collection/lib/iterable_zip.dart ('k') | pkg/polymer/lib/src/build/runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698