Chromium Code Reviews| 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 if (!Platform.isWindows) { | |
| 29 Expect.isTrue(Platform.executable.startsWith('/')); | |
| 30 } else { | |
| 31 Expect.equals(Platform.executable.substring(1, 3), ':\\'); | |
|
Lasse Reichstein Nielsen
2015/05/20 10:48:43
That's slightly optimistic in general, but probabl
Søren Gjesse
2015/05/20 11:14:24
True I am assuming that tests (both locally and on
| |
| 32 } | |
| 28 // Move directory to be sure script is correct. | 33 // Move directory to be sure script is correct. |
| 29 var oldDir = Directory.current; | 34 var oldDir = Directory.current; |
| 30 Directory.current = Directory.current.parent; | 35 Directory.current = Directory.current.parent; |
| 31 Expect.isTrue(Platform.script.path. | 36 Expect.isTrue(Platform.script.path. |
| 32 endsWith('tests/standalone/io/platform_test.dart')); | 37 endsWith('tests/standalone/io/platform_test.dart')); |
| 33 Expect.isTrue(Platform.script.toFilePath().startsWith(oldDir.path)); | 38 Expect.isTrue(Platform.script.toFilePath().startsWith(oldDir.path)); |
| 34 // Restore dir. | 39 // Restore dir. |
| 35 Directory.current = oldDir; | 40 Directory.current = oldDir; |
| 36 Directory packageRoot = new Directory(Platform.packageRoot); | 41 Directory packageRoot = new Directory(Platform.packageRoot); |
| 37 Expect.isTrue(packageRoot.existsSync()); | 42 Expect.isTrue(packageRoot.existsSync()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 Expect.throws(() => checkValidVersion('x.y.z')); | 122 Expect.throws(() => checkValidVersion('x.y.z')); |
| 118 } | 123 } |
| 119 | 124 |
| 120 main() { | 125 main() { |
| 121 // This tests assumes paths relative to dart main directory | 126 // This tests assumes paths relative to dart main directory |
| 122 Directory.current = Platform.script.resolve('../../..').toFilePath(); | 127 Directory.current = Platform.script.resolve('../../..').toFilePath(); |
| 123 test(); | 128 test(); |
| 124 testIsolate(); | 129 testIsolate(); |
| 125 testVersion(); | 130 testVersion(); |
| 126 } | 131 } |
| OLD | NEW |