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

Side by Side Diff: tests/isolate/stream_mangling_test.dart

Issue 11740027: Rename unsubscribe to cancel. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Fix error message. 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'dart:isolate'; 5 import 'dart:isolate';
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 7
8 main() { 8 main() {
9 test("Self referencing arrays serialize correctly", () { 9 test("Self referencing arrays serialize correctly", () {
10 var messageBox = new MessageBox(); 10 var messageBox = new MessageBox();
11 var stream = messageBox.stream; 11 var stream = messageBox.stream;
12 var sink = messageBox.sink; 12 var sink = messageBox.sink;
13 var nested = []; 13 var nested = [];
14 nested.add(nested); 14 nested.add(nested);
15 Expect.identical(nested, nested[0]); 15 Expect.identical(nested, nested[0]);
16 stream.subscribe(onData: expectAsync1((data) { 16 stream.listen(expectAsync1((data) {
17 Expect.isFalse(identical(nested, data)); 17 Expect.isFalse(identical(nested, data));
18 Expect.isTrue(data is List); 18 Expect.isTrue(data is List);
19 Expect.equals(1, data.length); 19 Expect.equals(1, data.length);
20 Expect.identical(data, data[0]); 20 Expect.identical(data, data[0]);
21 stream.close(); 21 stream.close();
22 })); 22 }));
23 sink.add(nested); 23 sink.add(nested);
24 }); 24 });
25 25
26 test("Self referencing arrays serialize correctly 2", () { 26 test("Self referencing arrays serialize correctly 2", () {
27 var messageBox = new MessageBox(); 27 var messageBox = new MessageBox();
28 var stream = messageBox.stream; 28 var stream = messageBox.stream;
29 var sink = messageBox.sink; 29 var sink = messageBox.sink;
30 var nested = [0, 1]; 30 var nested = [0, 1];
31 nested.add(nested); 31 nested.add(nested);
32 nested.add(3); 32 nested.add(3);
33 nested.add(4); 33 nested.add(4);
34 Expect.identical(nested, nested[2]); 34 Expect.identical(nested, nested[2]);
35 stream.subscribe(onData: expectAsync1((data) { 35 stream.listen(expectAsync1((data) {
36 Expect.isFalse(identical(nested, data)); 36 Expect.isFalse(identical(nested, data));
37 Expect.isTrue(data is List); 37 Expect.isTrue(data is List);
38 Expect.equals(5, data.length); 38 Expect.equals(5, data.length);
39 Expect.identical(data, data[2]); 39 Expect.identical(data, data[2]);
40 Expect.equals(0, data[0]); 40 Expect.equals(0, data[0]);
41 Expect.equals(1, data[1]); 41 Expect.equals(1, data[1]);
42 Expect.equals(3, data[3]); 42 Expect.equals(3, data[3]);
43 Expect.equals(4, data[4]); 43 Expect.equals(4, data[4]);
44 stream.close(); 44 stream.close();
45 })); 45 }));
46 sink.add(nested); 46 sink.add(nested);
47 }); 47 });
48 48
49 test("Self referencing arrays serialize correctly 3", () { 49 test("Self referencing arrays serialize correctly 3", () {
50 var messageBox = new MessageBox(); 50 var messageBox = new MessageBox();
51 var stream = messageBox.stream; 51 var stream = messageBox.stream;
52 var sink = messageBox.sink; 52 var sink = messageBox.sink;
53 var nested = [[[[[0, 1]]]]]; 53 var nested = [[[[[0, 1]]]]];
54 nested.add(nested); 54 nested.add(nested);
55 nested[0][0][0][0].add(nested); 55 nested[0][0][0][0].add(nested);
56 nested.add(3); 56 nested.add(3);
57 nested.add(4); 57 nested.add(4);
58 Expect.identical(nested, nested[0][0][0][0][2]); 58 Expect.identical(nested, nested[0][0][0][0][2]);
59 stream.subscribe(onData: expectAsync1((data) { 59 stream.listen(expectAsync1((data) {
60 Expect.isFalse(identical(nested, data)); 60 Expect.isFalse(identical(nested, data));
61 Expect.isTrue(data is List); 61 Expect.isTrue(data is List);
62 Expect.equals(4, data.length); 62 Expect.equals(4, data.length);
63 Expect.equals(1, data[0].length); 63 Expect.equals(1, data[0].length);
64 Expect.equals(1, data[0][0].length); 64 Expect.equals(1, data[0][0].length);
65 Expect.equals(1, data[0][0][0].length); 65 Expect.equals(1, data[0][0][0].length);
66 Expect.equals(3, data[0][0][0][0].length); 66 Expect.equals(3, data[0][0][0][0].length);
67 Expect.identical(data, data[0][0][0][0][2]); 67 Expect.identical(data, data[0][0][0][0][2]);
68 Expect.identical(data, data[1]); 68 Expect.identical(data, data[1]);
69 Expect.equals(3, data[2]); 69 Expect.equals(3, data[2]);
70 Expect.equals(4, data[3]); 70 Expect.equals(4, data[3]);
71 stream.close(); 71 stream.close();
72 })); 72 }));
73 sink.add(nested); 73 sink.add(nested);
74 }); 74 });
75 75
76 test("Self referencing maps serialize correctly", () { 76 test("Self referencing maps serialize correctly", () {
77 var messageBox = new MessageBox(); 77 var messageBox = new MessageBox();
78 var stream = messageBox.stream; 78 var stream = messageBox.stream;
79 var sink = messageBox.sink; 79 var sink = messageBox.sink;
80 var nested = {}; 80 var nested = {};
81 nested["foo"] = nested; 81 nested["foo"] = nested;
82 Expect.identical(nested, nested["foo"]); 82 Expect.identical(nested, nested["foo"]);
83 stream.subscribe(onData: expectAsync1((data) { 83 stream.listen(expectAsync1((data) {
84 Expect.isFalse(identical(nested, data)); 84 Expect.isFalse(identical(nested, data));
85 Expect.isTrue(data is Map); 85 Expect.isTrue(data is Map);
86 Expect.equals(1, data.length); 86 Expect.equals(1, data.length);
87 Expect.identical(data, data["foo"]); 87 Expect.identical(data, data["foo"]);
88 stream.close(); 88 stream.close();
89 })); 89 }));
90 sink.add(nested); 90 sink.add(nested);
91 }); 91 });
92 92
93 test("Sending of IsolateSinks", () { 93 test("Sending of IsolateSinks", () {
94 // TODO(floitsch): add test. 94 // TODO(floitsch): add test.
95 }); 95 });
96 96
97 test("Sending of IsolateSinks in complicated structures", () { 97 test("Sending of IsolateSinks in complicated structures", () {
98 // TODO(floitsch): add test. 98 // TODO(floitsch): add test.
99 }); 99 });
100 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698