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

Side by Side Diff: pkg/scheduled_test/test/scheduled_stream/stream_matcher_test.dart

Issue 524153002: Sharing metatest logic between unittest and scheduled_test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: status fixes Created 6 years, 3 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
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 library scheduled_test.stream_matcher_test; 5 library scheduled_test.stream_matcher_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:scheduled_test/scheduled_stream.dart'; 9 import 'package:scheduled_test/scheduled_stream.dart';
10 import 'package:scheduled_test/scheduled_test.dart'; 10 import 'package:scheduled_test/scheduled_test.dart';
11 import 'package:scheduled_test/src/utils.dart'; 11 import 'package:scheduled_test/src/utils.dart';
12 12
13 import '../metatest.dart'; 13 import 'package:metatest/metatest.dart';
14 import '../utils.dart'; 14 import '../utils.dart';
15 15
16 /// Returns a [ScheduledStream] that asynchronously emits the numbers 1 through 16 /// Returns a [ScheduledStream] that asynchronously emits the numbers 1 through
17 /// 5 and then closes. 17 /// 5 and then closes.
18 ScheduledStream createStream() { 18 ScheduledStream createStream() {
19 var controller = new StreamController(); 19 var controller = new StreamController();
20 var stream = new ScheduledStream(controller.stream); 20 var stream = new ScheduledStream(controller.stream);
21 21
22 var future = pumpEventQueue(); 22 var future = pumpEventQueue();
23 for (var i = 1; i <= 5; i++) { 23 for (var i = 1; i <= 5; i++) {
24 future = future.then((_) { 24 future = future.then((_) {
25 controller.add(i); 25 controller.add(i);
26 return pumpEventQueue(); 26 return pumpEventQueue();
27 }); 27 });
28 } 28 }
29 future.then((_) => controller.close()); 29 future.then((_) => controller.close());
30 30
31 return stream; 31 return stream;
32 } 32 }
33 33
34 void main(_, message) { 34 void main() => initTests(_test);
35
36 void _test(message) {
35 initMetatest(message); 37 initMetatest(message);
36 38
37 setUpTimeout(); 39 setUpTimeout();
38 40
39 expectTestPasses("expect() with matching values passes", () { 41 expectTestPasses("expect() with matching values passes", () {
40 var stream = createStream(); 42 var stream = createStream();
41 stream.expect(1); 43 stream.expect(1);
42 stream.expect(2); 44 stream.expect(2);
43 stream.expect(3); 45 stream.expect(3);
44 stream.expect(4); 46 stream.expect(4);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 expect(errors.first.error.message, equals( 326 expect(errors.first.error.message, equals(
325 "Expected: is done\n" 327 "Expected: is done\n"
326 " Emitted: * 1\n" 328 " Emitted: * 1\n"
327 " * 2\n" 329 " * 2\n"
328 " * 3\n" 330 " * 3\n"
329 " * 4\n" 331 " * 4\n"
330 " * 5\n" 332 " * 5\n"
331 " Which: stream wasn't finished")); 333 " Which: stream wasn't finished"));
332 }); 334 });
333 } 335 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/scheduled_server_test.dart ('k') | pkg/scheduled_test/test/scheduled_test/abort_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698