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

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

Issue 12041045: List.mappedBy/skip/take returns a List. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 11 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/iterable_skip_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
(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 main() {
6 List<int> list1 = <int>[1, 2, 3];
7 List<int> list2 = const <int>[4, 5];
8 List<String> list3 = <String>[];
9 Set<int> set1 = new Set<int>();
10 set1.addAll([11, 12, 13]);
11 Set set2 = new Set();
12
13 Iterable mapped = list1.mappedBy((x) => x + 1);
14 Expect.isTrue(mapped is List);
15 Expect.listEquals([2, 3, 4], mapped);
16
17 mapped = mapped.mappedBy((x) => x + 1);
18 Expect.isTrue(mapped is List);
19 Expect.listEquals([3, 4, 5], mapped);
20
21 mapped = list2.mappedBy((x) => x + 1);
22 Expect.isTrue(mapped is List);
23 Expect.listEquals([5, 6], mapped);
24
25 mapped = mapped.mappedBy((x) => x + 1);
26 Expect.isTrue(mapped is List);
27 Expect.listEquals([6, 7], mapped);
28
29 mapped = list3.mappedBy((x) => x + 1);
30 Expect.isTrue(mapped is List);
31 Expect.listEquals([], mapped);
32
33 mapped = mapped.mappedBy((x) => x + 1);
34 Expect.isTrue(mapped is List);
35 Expect.listEquals([], mapped);
36
37 var expected = new Set<int>()..addAll([12, 13, 14]);
38 mapped = set1.mappedBy((x) => x + 1);
39 Expect.isFalse(mapped is List);
40 Expect.setEquals(expected, mapped.toSet());
41
42 expected = new Set<int>()..addAll([13, 14, 15]);
43 mapped = mapped.mappedBy((x) => x + 1);
44 Expect.isFalse(mapped is List);
45 Expect.setEquals(expected, mapped.toSet());
46
47 mapped = set2.mappedBy((x) => x + 1);
48 Expect.isFalse(mapped is List);
49 Expect.listEquals([], mapped.toList());
50
51 mapped = mapped.mappedBy((x) => x + 1);
52 Expect.isFalse(mapped is List);
53 Expect.listEquals([], mapped.toList());
54
55 }
OLDNEW
« no previous file with comments | « sdk/lib/core/list.dart ('k') | tests/corelib/iterable_skip_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698