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

Unified Diff: tests/isolate/src/MessageTest.dart

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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/src/Message2Test.dart ('k') | tests/isolate/src/MintMakerTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/src/MessageTest.dart
diff --git a/tests/isolate/src/MessageTest.dart b/tests/isolate/src/MessageTest.dart
index 3eea9a012297f55fd6fe08d549aeb53b354c99cb..04c83f332ec42b028a508a2701e5b2431fb8acb0 100644
--- a/tests/isolate/src/MessageTest.dart
+++ b/tests/isolate/src/MessageTest.dart
@@ -7,17 +7,13 @@
#library('MessageTest');
#import("dart:isolate");
-#import("TestFramework.dart");
+#import('../../../lib/unittest/unittest.dart');
// ---------------------------------------------------------------------------
// Message passing test.
// ---------------------------------------------------------------------------
class MessageTest {
- static void test(TestExpectation expect) {
- PingPongClient.test(expect);
- }
-
static final List list1 = const ["Hello", "World", "Hello", 0xfffffffffff];
static final List list2 = const [null, list1, list1, list1, list1];
static final List list3 = const [list2, 2.0, true, false, 0xfffffffffff];
@@ -67,9 +63,33 @@ class MessageTest {
}
}
-class PingPongClient {
- static void test(TestExpectation expect) {
- expect.completes(new PingPongServer().spawn()).then((SendPort remote) {
+class PingPongServer extends Isolate {
+ PingPongServer() : super() {}
+
+ void main() {
+ int count = 0;
+ this.port.receive(
+ (var message, SendPort replyTo) {
+ if (message == -1) {
+ this.port.close();
+ replyTo.send(count, null);
+ } else {
+ // Check if the received object is correct.
+ if (count < MessageTest.elms.length) {
+ MessageTest.VerifyObject(count, message);
+ }
+ // Bounce the received object back so that the sender
+ // can make sure that the object matches.
+ replyTo.send(message, null);
+ count++;
+ }
+ });
+ }
+}
+
+main() {
+ test("send objects and receive them back", () {
+ new PingPongServer().spawn().then(expectAsync1((SendPort remote) {
// Send objects and receive them back.
for (int i = 0; i < MessageTest.elms.length; i++) {
@@ -77,7 +97,7 @@ class PingPongClient {
// TODO(asiva): remove this local var idx once thew new for-loop
// semantics for closures is implemented.
var idx = i;
- remote.call(sentObject).then(expect.runs1((var receivedObject) {
+ remote.call(sentObject).then(expectAsync1((var receivedObject) {
MessageTest.VerifyObject(idx, receivedObject);
}));
}
@@ -93,52 +113,23 @@ class PingPongClient {
sendObject[3] = sendObject;
sendObject[4] = local_list3;
remote.call(sendObject).then((var replyObject) {
- Expect.equals(true, sendObject is List);
- Expect.equals(true, replyObject is List);
- Expect.equals(sendObject.length, replyObject.length);
- Expect.equals(true, replyObject[1] === replyObject);
- Expect.equals(true, replyObject[3] === replyObject);
- Expect.equals(true, replyObject[0] === replyObject[2][1]);
- Expect.equals(true, replyObject[0] === replyObject[2][2]);
- Expect.equals(true, replyObject[2] === replyObject[4][0]);
- Expect.equals(true, replyObject[0][0] === replyObject[0][2]);
- // Bigint literals are not canonicalized so do a == check.
- Expect.equals(true, replyObject[0][3] == replyObject[4][4]);
- });
+ Expect.equals(true, sendObject is List);
+ Expect.equals(true, replyObject is List);
+ Expect.equals(sendObject.length, replyObject.length);
+ Expect.equals(true, replyObject[1] === replyObject);
+ Expect.equals(true, replyObject[3] === replyObject);
+ Expect.equals(true, replyObject[0] === replyObject[2][1]);
+ Expect.equals(true, replyObject[0] === replyObject[2][2]);
+ Expect.equals(true, replyObject[2] === replyObject[4][0]);
+ Expect.equals(true, replyObject[0][0] === replyObject[0][2]);
+ // Bigint literals are not canonicalized so do a == check.
+ Expect.equals(true, replyObject[0][3] == replyObject[4][4]);
+ });
// Shutdown the MessageServer.
- remote.call(-1).then(expect.runs1((int message) {
+ remote.call(-1).then(expectAsync1((int message) {
Expect.equals(MessageTest.elms.length + 1, message);
- expect.succeeded();
}));
- });
- }
-}
-
-class PingPongServer extends Isolate {
- PingPongServer() : super() {}
-
- void main() {
- int count = 0;
- this.port.receive(
- (var message, SendPort replyTo) {
- if (message == -1) {
- this.port.close();
- replyTo.send(count, null);
- } else {
- // Check if the received object is correct.
- if (count < MessageTest.elms.length) {
- MessageTest.VerifyObject(count, message);
- }
- // Bounce the received object back so that the sender
- // can make sure that the object matches.
- replyTo.send(message, null);
- count++;
- }
- });
- }
-}
-
-main() {
- runTests([MessageTest.test]);
+ }));
+ });
}
« no previous file with comments | « tests/isolate/src/Message2Test.dart ('k') | tests/isolate/src/MintMakerTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698