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

Unified Diff: tests/standalone/io/platform_test.dart

Issue 22565003: Make the values of Platform.executable and Platform.script available to all isolates (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« sdk/lib/io/platform_impl.dart ('K') | « sdk/lib/io/platform_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/platform_test.dart
diff --git a/tests/standalone/io/platform_test.dart b/tests/standalone/io/platform_test.dart
index ce6e9776c05d769f3d0ac53ef154888a4d5a303e..d694b4c78029af82c45ffee6163db966dac67aee 100644
--- a/tests/standalone/io/platform_test.dart
+++ b/tests/standalone/io/platform_test.dart
@@ -3,9 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
+import "dart:async";
import "dart:io";
+import "dart:isolate";
-main() {
+test() {
Expect.isTrue(Platform.numberOfProcessors > 0);
var os = Platform.operatingSystem;
Expect.isTrue(os == "android" || os == "linux" || os == "macos" ||
@@ -24,3 +26,50 @@ main() {
Expect.isTrue(Platform.script.replaceAll('\\', '/').
endsWith('tests/standalone/io/platform_test.dart'));
}
+
+void f() {
+ port.receive((msg, reply) {
+ if (msg == "Platform.executable") {
+ reply.send(Platform.executable);
+ }
+ if (msg == "Platform.script") {
+ reply.send(Platform.script);
+ }
+ if (msg == "new Options().executable") {
+ reply.send(new Options().executable);
+ }
+ if (msg == "new Options().script") {
+ reply.send(new Options().script);
+ }
+ if (msg == "close") {
+ reply.send("closed");
+ port.close();
+ }
+ });
+}
+
+testIsolate() {
+ var port = new ReceivePort();
+ print("Executable outside isolate: '${new Options().executable}'");
Bill Hesse 2013/08/07 13:39:44 Remove debug printing
Søren Gjesse 2013/08/07 14:37:46 Done.
+ print("Script outside isolate: '${new Options().script}'");
+ var sendPort = spawnFunction(f);
+ var futures = new List(4);
Bill Hesse 2013/08/07 13:39:44 Could you use a list literal here? Futures.wait([s
Søren Gjesse 2013/08/07 14:37:46 Done.
+ futures[0] = sendPort.call("Platform.executable");
+ futures[1] = sendPort.call("Platform.script");
+ futures[2] = sendPort.call("new Options().executable");
+ futures[3] = sendPort.call("new Options().script");
+ Future.wait(futures).then((results) {
+ Expect.equals(Platform.executable, results[0]);
+ Expect.equals(Platform.executable, results[2]);
+ Uri uri = Uri.parse(results[1]);
+ Expect.equals(uri, Uri.parse(results[3]));
+ Expect.equals("file", uri.scheme);
+ Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart'));
+ sendPort.call("close").then((_) => port.close());
+ });
+}
+
+main() {
+ test();
+ testIsolate();
+}
« sdk/lib/io/platform_impl.dart ('K') | « sdk/lib/io/platform_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698