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

Side by Side Diff: tests/lib/async/stream_from_iterable_test.dart

Issue 12090093: Reapply "Rename mappedBy to map." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed bug in previous commit. Created 7 years, 10 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 | « tests/lib/async/stream_controller_test.dart ('k') | tools/dom/src/CssClassSet.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test merging streams. 5 // Test merging streams.
6 library dart.test.stream_from_iterable; 6 library dart.test.stream_from_iterable;
7 7
8 import "dart:async"; 8 import "dart:async";
9 import '../../../pkg/unittest/lib/unittest.dart'; 9 import '../../../pkg/unittest/lib/unittest.dart';
10 import 'event_helper.dart'; 10 import 'event_helper.dart';
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 main() { 28 main() {
29 new IterableTest([]).run(); 29 new IterableTest([]).run();
30 new IterableTest([1]).run(); 30 new IterableTest([1]).run();
31 new IterableTest([1, "two", true, null]).run(); 31 new IterableTest([1, "two", true, null]).run();
32 new IterableTest<int>([1, 2, 3, 4]).run(); 32 new IterableTest<int>([1, 2, 3, 4]).run();
33 new IterableTest<String>(["one", "two", "three", "four"]).run(); 33 new IterableTest<String>(["one", "two", "three", "four"]).run();
34 new IterableTest<int>(new Iterable<int>.generate(1000, (i) => i)).run(); 34 new IterableTest<int>(new Iterable<int>.generate(1000, (i) => i)).run();
35 new IterableTest<String>(new Iterable<int>.generate(1000, (i) => i) 35 new IterableTest<String>(new Iterable<int>.generate(1000, (i) => i)
36 .mappedBy((i) => "$i")).run(); 36 .map((i) => "$i")).run();
37 37
38 Iterable<int> iter = new Iterable.generate(25, (i) => i * 2); 38 Iterable<int> iter = new Iterable.generate(25, (i) => i * 2);
39 39
40 test("iterable-toList", () { 40 test("iterable-toList", () {
41 new Stream.fromIterable(iter).toList().then(expectAsync1((actual) { 41 new Stream.fromIterable(iter).toList().then(expectAsync1((actual) {
42 List expected = iter.toList(); 42 List expected = iter.toList();
43 Expect.equals(25, expected.length); 43 Expect.equals(25, expected.length);
44 Expect.listEquals(expected, actual); 44 Expect.listEquals(expected, actual);
45 })); 45 }));
46 }); 46 });
47 47
48 test("iterable-mapped-toList", () { 48 test("iterable-mapped-toList", () {
49 new Stream.fromIterable(iter) 49 new Stream.fromIterable(iter)
50 .mappedBy((i) => i * 3) 50 .map((i) => i * 3)
51 .toList() 51 .toList()
52 .then(expectAsync1((actual) { 52 .then(expectAsync1((actual) {
53 List expected = iter.mappedBy((i) => i * 3).toList(); 53 List expected = iter.map((i) => i * 3).toList();
54 Expect.listEquals(expected, actual); 54 Expect.listEquals(expected, actual);
55 })); 55 }));
56 }); 56 });
57 57
58 test("iterable-paused", () { 58 test("iterable-paused", () {
59 Stream stream = new Stream.fromIterable(iter); 59 Stream stream = new Stream.fromIterable(iter);
60 Events actual = new Events(); 60 Events actual = new Events();
61 StreamSubscription subscription; 61 StreamSubscription subscription;
62 subscription = stream.listen((int value) { 62 subscription = stream.listen((int value) {
63 actual.add(value); 63 actual.add(value);
64 // Do a 10 ms pause during the playback of the iterable. 64 // Do a 10 ms pause during the playback of the iterable.
65 if (value == 20) { subscription.pause(new Future.delayed(10, () {})); } 65 if (value == 20) { subscription.pause(new Future.delayed(10, () {})); }
66 }, onDone: expectAsync0(() { 66 }, onDone: expectAsync0(() {
67 actual.close(); 67 actual.close();
68 Events expected = new Events.fromIterable(iter); 68 Events expected = new Events.fromIterable(iter);
69 Expect.listEquals(expected.events, actual.events); 69 Expect.listEquals(expected.events, actual.events);
70 })); 70 }));
71 }); 71 });
72 } 72 }
OLDNEW
« no previous file with comments | « tests/lib/async/stream_controller_test.dart ('k') | tools/dom/src/CssClassSet.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698