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

Unified Diff: tests/isolate/count_stream_test.dart

Issue 12919011: Remove streamSpawnUri and mangler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: tests/isolate/count_stream_test.dart
diff --git a/tests/isolate/count_stream_test.dart b/tests/isolate/count_stream_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7c1ace62115a5a425239053bcd62d7faf401c87e
--- /dev/null
+++ b/tests/isolate/count_stream_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library CountTest;
+import '../../pkg/unittest/lib/unittest.dart';
+import 'dart:isolate';
+
+void countMessages() {
+ int count = 0;
+ IsolateSink replySink;
+ bool isFirst = true;
+ stream.listen((msg) {
Lasse Reichstein Nielsen 2013/03/19 12:01:55 Where is "stream" declared?
floitsch 2013/03/19 13:18:59 Top level from async.
+ if (isFirst) {
+ replySink = msg;
+ isFirst = false;
+ return;
+ }
+ replySink.add(count);
+ count++;
+ }, onDone: () {
+ expect(count, 10);
+ replySink.close();
+ });
+}
+
+void main() {
+ test("count 10 consecutive stream messages", () {
+ int count = 0;
+ MessageBox box = new MessageBox();
+ IsolateSink remote = streamSpawnFunction(countMessages);
+ remote.add(box.sink);
+ box.stream.listen(expectAsync1((remoteCount) {
+ expect(remoteCount, count);
+ count++;
+ if (count < 10) {
+ remote.add(count);
Lasse Reichstein Nielsen 2013/03/19 12:01:55 Don't send "count" here. Just send null. It looks
floitsch 2013/03/19 13:18:59 Done.
+ } else {
+ remote.close();
+ }
+ }, count: 10), onDone: expectAsync0(() {
+ expect(count, 10);
+ }));
+ remote.add(0);
Lasse Reichstein Nielsen 2013/03/19 12:01:55 Send null.
floitsch 2013/03/19 13:18:59 Done.
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698