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

Side by Side Diff: packages/collection/test/combined_wrapper/iterable_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2017, 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 'package:collection/collection.dart';
6 import 'package:test/test.dart';
7
8 void main() {
9 var iterable1 = new Iterable.generate(3);
10 var iterable2 = new Iterable.generate(3, (i) => i + 3);
11 var iterable3 = new Iterable.generate(3, (i) => i + 6);
12
13 test('should combine multiple iterables when iterating', () {
14 var combined = new CombinedIterableView([iterable1, iterable2, iterable3]);
15 expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
16 });
17
18 test('should combine multiple iterables with some empty ones', () {
19 var combined =
20 new CombinedIterableView([iterable1, [], iterable2, [], iterable3, []]);
21 expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
22 });
23
24 test('should function as an empty iterable when no iterables are passed', () {
25 var empty = new CombinedIterableView([]);
26 expect(empty, isEmpty);
27 });
28
29 test('should function as an empty iterable with all empty iterables', () {
30 var empty = new CombinedIterableView([[], [], []]);
31 expect(empty, isEmpty);
32 });
33
34 test('should reflect changes from the underlying iterables', () {
35 var list1 = [];
36 var list2 = [];
37 var combined = new CombinedIterableView([list1, list2]);
38 expect(combined, isEmpty);
39 list1.addAll([1, 2]);
40 list2.addAll([3, 4]);
41 expect(combined, [1, 2, 3, 4]);
42 expect(combined.last, 4);
43 expect(combined.first, 1);
44 });
45
46 test('should reflect changes from the iterable of iterables', () {
47 var iterables = <Iterable>[];
48 var combined = new CombinedIterableView(iterables);
49 expect(combined, isEmpty);
50 expect(combined, hasLength(0));
51
52 iterables.add(iterable1);
53 expect(combined, isNotEmpty);
54 expect(combined, hasLength(3));
55
56 iterables.clear();
57 expect(combined, isEmpty);
58 expect(combined, hasLength(0));
59 });
60 }
OLDNEW
« no previous file with comments | « packages/collection/test/canonicalized_map_test.dart ('k') | packages/collection/test/combined_wrapper/list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698