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

Side by Side Diff: tests/standalone/io/platform_test.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Anders' comment. Created 7 years, 1 month 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:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 import "dart:isolate"; 7 import "dart:isolate";
8 8
9 import "package:async_helper/async_helper.dart"; 9 import "package:async_helper/async_helper.dart";
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 16 matching lines...) Expand all
27 Expect.isTrue(Platform.executable.contains('dart')); 27 Expect.isTrue(Platform.executable.contains('dart'));
28 Expect.isTrue(Platform.script.replaceAll('\\', '/'). 28 Expect.isTrue(Platform.script.replaceAll('\\', '/').
29 endsWith('tests/standalone/io/platform_test.dart')); 29 endsWith('tests/standalone/io/platform_test.dart'));
30 Directory packageRoot = new Directory(Platform.packageRoot); 30 Directory packageRoot = new Directory(Platform.packageRoot);
31 Expect.isTrue(packageRoot.existsSync()); 31 Expect.isTrue(packageRoot.existsSync());
32 Expect.isTrue(new Directory("${packageRoot.path}/expect").existsSync()); 32 Expect.isTrue(new Directory("${packageRoot.path}/expect").existsSync());
33 Expect.isTrue(Platform.executableArguments.any( 33 Expect.isTrue(Platform.executableArguments.any(
34 (arg) => arg.contains(Platform.packageRoot))); 34 (arg) => arg.contains(Platform.packageRoot)));
35 } 35 }
36 36
37 void f() { 37 void f(reply) {
38 port.receive((msg, reply) { 38 reply.send({"Platform.executable": Platform.executable,
39 if (msg == "Platform.executable") { 39 "Platform.script": Platform.script,
40 reply.send(Platform.executable); 40 "Platform.packageRoot": Platform.packageRoot,
41 } 41 "Platform.executableArguments": Platform.executableArguments});
42 if (msg == "Platform.script") {
43 reply.send(Platform.script);
44 }
45 if (msg == "Platform.packageRoot") {
46 reply.send(Platform.packageRoot);
47 }
48 if (msg == "Platform.executableArguments") {
49 reply.send(Platform.executableArguments);
50 }
51 if (msg == "close") {
52 reply.send("closed");
53 port.close();
54 }
55 });
56 } 42 }
57 43
58 testIsolate() { 44 testIsolate() {
59 asyncStart(); 45 asyncStart();
60 var sendPort = spawnFunction(f); 46 ReceivePort port = new ReceivePort();
61 Future.wait([sendPort.call("Platform.executable"), 47 var remote = Isolate.spawn(f, port.sendPort);
62 sendPort.call("Platform.script"), 48 port.first.then((results) {
63 sendPort.call("Platform.packageRoot"), 49 Expect.equals(Platform.executable, results["Platform.executable"]);
64 sendPort.call("Platform.executableArguments")]) 50
65 .then((results) { 51 Uri uri = Uri.parse(results["Platform.script"]);
66 Expect.equals(Platform.executable, results[0]);
67 Uri uri = Uri.parse(results[1]);
68 Expect.equals("file", uri.scheme); 52 Expect.equals("file", uri.scheme);
69 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart')); 53 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart'));
70 Expect.equals(Platform.packageRoot, results[2]); 54 Expect.equals(Platform.packageRoot, results["Platform.packageRoot"]);
71 Expect.listEquals(Platform.executableArguments, results[3]); 55 Expect.listEquals(Platform.executableArguments,
72 sendPort.call("close").then((_) => asyncEnd()); 56 results["Platform.executableArguments"]);
57 asyncEnd();
73 }); 58 });
74 } 59 }
75 60
76 main() { 61 main() {
77 test(); 62 test();
78 testIsolate(); 63 testIsolate();
79 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698