Chromium Code Reviews| 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(); |
| +} |