| OLD | NEW |
| 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 "package:expect/expect.dart"; | |
| 6 import "dart:async"; | 5 import "dart:async"; |
| 7 import "dart:io"; | 6 import "dart:io"; |
| 8 import "dart:isolate"; | 7 import "dart:isolate"; |
| 9 | 8 |
| 9 import "package:async_helper/async_helper.dart"; |
| 10 import "package:expect/expect.dart"; |
| 11 |
| 10 test() { | 12 test() { |
| 11 Expect.isTrue(Platform.numberOfProcessors > 0); | 13 Expect.isTrue(Platform.numberOfProcessors > 0); |
| 12 var os = Platform.operatingSystem; | 14 var os = Platform.operatingSystem; |
| 13 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || | 15 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || |
| 14 os == "windows"); | 16 os == "windows"); |
| 15 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); | 17 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); |
| 16 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); | 18 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); |
| 17 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); | 19 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); |
| 18 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); | 20 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); |
| 19 var sep = Platform.pathSeparator; | 21 var sep = Platform.pathSeparator; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 reply.send(new Options().script); | 55 reply.send(new Options().script); |
| 54 } | 56 } |
| 55 if (msg == "close") { | 57 if (msg == "close") { |
| 56 reply.send("closed"); | 58 reply.send("closed"); |
| 57 port.close(); | 59 port.close(); |
| 58 } | 60 } |
| 59 }); | 61 }); |
| 60 } | 62 } |
| 61 | 63 |
| 62 testIsolate() { | 64 testIsolate() { |
| 63 var port = new ReceivePort(); | 65 asyncStart(); |
| 64 var sendPort = spawnFunction(f); | 66 var sendPort = spawnFunction(f); |
| 65 Future.wait([sendPort.call("Platform.executable"), | 67 Future.wait([sendPort.call("Platform.executable"), |
| 66 sendPort.call("Platform.script"), | 68 sendPort.call("Platform.script"), |
| 67 sendPort.call("Platform.packageRoot"), | 69 sendPort.call("Platform.packageRoot"), |
| 68 sendPort.call("Platform.executableArguments"), | 70 sendPort.call("Platform.executableArguments"), |
| 69 sendPort.call("new Options().executable"), | 71 sendPort.call("new Options().executable"), |
| 70 sendPort.call("new Options().script")]) | 72 sendPort.call("new Options().script")]) |
| 71 .then((results) { | 73 .then((results) { |
| 72 Expect.equals(Platform.executable, results[0]); | 74 Expect.equals(Platform.executable, results[0]); |
| 73 Expect.equals(Platform.executable, results[4]); | 75 Expect.equals(Platform.executable, results[4]); |
| 74 Uri uri = Uri.parse(results[1]); | 76 Uri uri = Uri.parse(results[1]); |
| 75 Expect.equals(uri, Uri.parse(results[5])); | 77 Expect.equals(uri, Uri.parse(results[5])); |
| 76 Expect.equals("file", uri.scheme); | 78 Expect.equals("file", uri.scheme); |
| 77 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart')); | 79 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart')); |
| 78 Expect.equals(Platform.packageRoot, results[2]); | 80 Expect.equals(Platform.packageRoot, results[2]); |
| 79 Expect.listEquals(Platform.executableArguments, results[3]); | 81 Expect.listEquals(Platform.executableArguments, results[3]); |
| 80 sendPort.call("close").then((_) => port.close()); | 82 sendPort.call("close").then((_) => asyncEnd()); |
| 81 }); | 83 }); |
| 82 } | 84 } |
| 83 | 85 |
| 84 main() { | 86 main() { |
| 85 test(); | 87 test(); |
| 86 testIsolate(); | 88 testIsolate(); |
| 87 } | 89 } |
| OLD | NEW |