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

Unified Diff: tests/isolate/isolate_complex_messages_stream_test.dart

Issue 12919011: Remove streamSpawnUri and mangler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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
« no previous file with comments | « tests/isolate/isolate.status ('k') | tests/isolate/mandel_isolate_stream_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/isolate_complex_messages_stream_test.dart
diff --git a/tests/isolate/isolate_complex_messages_stream_test.dart b/tests/isolate/isolate_complex_messages_stream_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..219b289a52bf4ef68018722cdad352c22ebf3332
--- /dev/null
+++ b/tests/isolate/isolate_complex_messages_stream_test.dart
@@ -0,0 +1,78 @@
+// 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.
+
+// Dart test program for testing isolate communication with
+// complex messages.
+
+library IsolateComplexMessagesTest;
+import 'dart:isolate';
+import '../../pkg/unittest/lib/unittest.dart';
+
+main() {
+ test("complex messages are serialized correctly", () {
+ var box = new MessageBox();
+ IsolateSink remote = streamSpawnFunction(logMessages);
+ remote.add(1);
+ remote.add("Hello");
+ remote.add("World");
+ remote.add(const [null, 1, 2, 3, 4]);
+ remote.add(const [1, 2.0, true, false, 0xffffffffff]);
+ remote.add(const ["Hello", "World", 0xffffffffff]);
+ remote.add(box.sink);
+ remote.close();
+ box.stream.single.then((message) {
+ expect(message, 7);
+ });
+ });
+}
+
+
+void logMessages() {
+ int count = 0;
+ IsolateSink replySink;
+
+ stream.listen((message) {
+ switch (count) {
+ case 0:
+ expect(message, 1);
+ break;
+ case 1:
+ expect(message, "Hello");
+ break;
+ case 2:
+ expect(message, "World");
+ break;
+ case 3:
+ expect(message.length, 5);
+ expect(message[0], null);
+ expect(message[1], 1);
+ expect(message[2], 2);
+ expect(message[3], 3);
+ expect(message[4], 4);
+ break;
+ case 4:
+ expect(message.length, 5);
+ expect(message[0], 1);
+ expect(message[1], 2.0);
+ expect(message[2], true);
+ expect(message[3], false);
+ expect(message[4], 0xffffffffff);
+ break;
+ case 5:
+ expect(message.length, 3);
+ expect(message[0], "Hello");
+ expect(message[1], "World");
+ expect(message[2], 0xffffffffff);
+ break;
+ case 6:
+ replySink = message;
+ break;
+ }
+ count++;
+ },
+ onDone: () {
+ replySink.add(count);
+ replySink.close();
+ });
+}
« no previous file with comments | « tests/isolate/isolate.status ('k') | tests/isolate/mandel_isolate_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698