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

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: 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
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..add(11)
Lasse Reichstein Nielsen 2013/01/24 06:49:32 Why not set1.addAll([1, 2, 3]); ? What is the purp
floitsch 2013/01/24 13:48:34 Done.
11 ..add(12)
12 ..add(13);
13 Set set2 = new Set();
14
15 Iterable mapped = list1.mappedBy((x) => x + 1);
Lasse Reichstein Nielsen 2013/01/24 06:49:32 Why "Iterable" and not "List"?
floitsch 2013/01/24 13:48:34 Because I want to prepare for the change back.
16 Expect.isTrue(mapped is List);
17 Expect.listEquals([2, 3, 4], mapped.toList());
Lasse Reichstein Nielsen 2013/01/24 06:49:32 And why .toList then?
floitsch 2013/01/24 13:48:34 removed.
18
19 mapped = mapped.mappedBy((x) => x + 1);
20 Expect.isTrue(mapped is List);
21 Expect.listEquals([3, 4, 5], mapped.toList());
22
23 mapped = list2.mappedBy((x) => x + 1);
24 Expect.isTrue(mapped is List);
25 Expect.listEquals([5, 6], mapped.toList());
26
27 mapped = mapped.mappedBy((x) => x + 1);
28 Expect.isTrue(mapped is List);
29 Expect.listEquals([6, 7], mapped.toList());
30
31 mapped = list3.mappedBy((x) => x + 1);
32 Expect.isTrue(mapped is List);
33 Expect.listEquals([], mapped.toList());
34
35 mapped = mapped.mappedBy((x) => x + 1);
36 Expect.isTrue(mapped is List);
37 Expect.listEquals([], mapped.toList());
38
39 var expected = new Set<int>()..add(12)..add(13)..add(14);
40 mapped = set1.mappedBy((x) => x + 1);
41 Expect.isFalse(mapped is List);
42 Expect.setEquals(expected, mapped.toSet());
43
44 expected = new Set<int>()..add(13)..add(14)..add(15);
45 mapped = mapped.mappedBy((x) => x + 1);
46 Expect.isFalse(mapped is List);
47 Expect.setEquals(expected, mapped.toSet());
48
49 mapped = set2.mappedBy((x) => x + 1);
50 Expect.isFalse(mapped is List);
51 Expect.listEquals([], mapped.toList());
52
53 mapped = mapped.mappedBy((x) => x + 1);
54 Expect.isFalse(mapped is List);
55 Expect.listEquals([], mapped.toList());
56
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698