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

Side by Side 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: Addressed review comments from whesse@ 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/platform_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"; 5 import "package:expect/expect.dart";
6 import "dart:async";
6 import "dart:io"; 7 import "dart:io";
8 import "dart:isolate";
7 9
8 main() { 10 test() {
9 Expect.isTrue(Platform.numberOfProcessors > 0); 11 Expect.isTrue(Platform.numberOfProcessors > 0);
10 var os = Platform.operatingSystem; 12 var os = Platform.operatingSystem;
11 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || 13 Expect.isTrue(os == "android" || os == "linux" || os == "macos" ||
12 os == "windows"); 14 os == "windows");
13 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); 15 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux");
14 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); 16 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos");
15 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); 17 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows");
16 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); 18 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android");
17 var sep = Platform.pathSeparator; 19 var sep = Platform.pathSeparator;
18 Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\')); 20 Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\'));
19 var hostname = Platform.localHostname; 21 var hostname = Platform.localHostname;
20 Expect.isTrue(hostname is String && hostname != ""); 22 Expect.isTrue(hostname is String && hostname != "");
21 var environment = Platform.environment; 23 var environment = Platform.environment;
22 Expect.isTrue(environment is Map<String, String>); 24 Expect.isTrue(environment is Map<String, String>);
23 Expect.isTrue(Platform.executable.contains('dart')); 25 Expect.isTrue(Platform.executable.contains('dart'));
24 Expect.isTrue(Platform.script.replaceAll('\\', '/'). 26 Expect.isTrue(Platform.script.replaceAll('\\', '/').
25 endsWith('tests/standalone/io/platform_test.dart')); 27 endsWith('tests/standalone/io/platform_test.dart'));
26 } 28 }
29
30 void f() {
31 port.receive((msg, reply) {
32 if (msg == "Platform.executable") {
33 reply.send(Platform.executable);
34 }
35 if (msg == "Platform.script") {
36 reply.send(Platform.script);
37 }
38 if (msg == "new Options().executable") {
39 reply.send(new Options().executable);
40 }
41 if (msg == "new Options().script") {
42 reply.send(new Options().script);
43 }
44 if (msg == "close") {
45 reply.send("closed");
46 port.close();
47 }
48 });
49 }
50
51 testIsolate() {
52 var port = new ReceivePort();
53 var sendPort = spawnFunction(f);
54 Future.wait([sendPort.call("Platform.executable"),
55 sendPort.call("Platform.script"),
56 sendPort.call("new Options().executable"),
57 sendPort.call("new Options().script")])
58 .then((results) {
59 Expect.equals(Platform.executable, results[0]);
60 Expect.equals(Platform.executable, results[2]);
61 Uri uri = Uri.parse(results[1]);
62 Expect.equals(uri, Uri.parse(results[3]));
63 Expect.equals("file", uri.scheme);
64 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart'));
65 sendPort.call("close").then((_) => port.close());
66 });
67 }
68
69 main() {
70 test();
71 testIsolate();
72 }
OLDNEW
« no previous file with comments | « sdk/lib/io/platform_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698