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 "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"; |
11 | 11 |
12 test() { | 12 test() { |
13 Expect.isTrue(Platform.numberOfProcessors > 0); | 13 Expect.isTrue(Platform.numberOfProcessors > 0); |
14 var os = Platform.operatingSystem; | 14 var os = Platform.operatingSystem; |
15 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || | 15 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || |
16 os == "windows"); | 16 os == "windows"); |
17 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); | 17 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); |
18 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); | 18 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); |
19 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); | 19 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); |
20 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); | 20 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); |
21 var sep = Platform.pathSeparator; | 21 var sep = Platform.pathSeparator; |
22 Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\')); | 22 Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\')); |
23 var hostname = Platform.localHostname; | 23 var hostname = Platform.localHostname; |
24 Expect.isTrue(hostname is String && hostname != ""); | 24 Expect.isTrue(hostname is String && hostname != ""); |
25 var environment = Platform.environment; | 25 var environment = Platform.environment; |
26 Expect.isTrue(environment is Map<String, String>); | 26 Expect.isTrue(environment is Map<String, String>); |
27 Expect.isTrue(Platform.executable.contains('dart')); | 27 Expect.isTrue(Platform.executable.contains('dart')); |
| 28 // Move directory to be sure script is correct. |
| 29 var oldDir = Directory.current; |
| 30 Directory.current = Directory.current.parent; |
28 Expect.isTrue(Platform.script.path. | 31 Expect.isTrue(Platform.script.path. |
29 endsWith('tests/standalone/io/platform_test.dart')); | 32 endsWith('tests/standalone/io/platform_test.dart')); |
| 33 Expect.isTrue(Platform.script.path.startsWith(oldDir.path)); |
| 34 // Restore dir. |
| 35 Directory.current = oldDir; |
30 Directory packageRoot = new Directory(Platform.packageRoot); | 36 Directory packageRoot = new Directory(Platform.packageRoot); |
31 Expect.isTrue(packageRoot.existsSync()); | 37 Expect.isTrue(packageRoot.existsSync()); |
32 Expect.isTrue(new Directory("${packageRoot.path}/expect").existsSync()); | 38 Expect.isTrue(new Directory("${packageRoot.path}/expect").existsSync()); |
33 Expect.isTrue(Platform.executableArguments.any( | 39 Expect.isTrue(Platform.executableArguments.any( |
34 (arg) => arg.contains(Platform.packageRoot))); | 40 (arg) => arg.contains(Platform.packageRoot))); |
35 } | 41 } |
36 | 42 |
37 void f(reply) { | 43 void f(reply) { |
38 reply.send({"Platform.executable": Platform.executable, | 44 reply.send({"Platform.executable": Platform.executable, |
39 "Platform.script": Platform.script, | 45 "Platform.script": Platform.script, |
(...skipping 17 matching lines...) Expand all Loading... |
57 Expect.listEquals(Platform.executableArguments, | 63 Expect.listEquals(Platform.executableArguments, |
58 results["Platform.executableArguments"]); | 64 results["Platform.executableArguments"]); |
59 asyncEnd(); | 65 asyncEnd(); |
60 }); | 66 }); |
61 } | 67 } |
62 | 68 |
63 main() { | 69 main() { |
64 test(); | 70 test(); |
65 testIsolate(); | 71 testIsolate(); |
66 } | 72 } |
OLD | NEW |