Clean up Platform.lineTerminator test.

Change-Id: I933956de806d9b4597385cf4afa4a98528c2165c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313542
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
This commit is contained in:
Brian Quinlan 2023-07-19 20:23:51 +00:00 committed by Commit Queue
parent 69f95fa2cd
commit e75cacf2b8
2 changed files with 14 additions and 12 deletions

View file

@ -30,12 +30,13 @@ test() {
Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos");
Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows");
Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android");
var sep = Platform.pathSeparator;
Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\'));
final eol = Platform.lineTerminator;
Expect.isTrue(
(eol == '\n' && os != 'windows') || (eol == '\r\n' && os == 'windows'),
"unexpected line ending ${utf8.encode(eol)} on $os");
if (Platform.isWindows) {
Expect.equals("\r\n", Platform.lineTerminator, "windows lineTerminator");
Expect.equals("\\", Platform.pathSeparator, "$os path-seperator");
} else {
Expect.equals("\n", Platform.lineTerminator, "$os lineTerminator");
Expect.equals("/", Platform.pathSeparator, "$os path-seperator");
}
var hostname = Platform.localHostname;
Expect.isTrue(hostname is String && hostname != "");
var environment = Platform.environment;

View file

@ -32,12 +32,13 @@ test() {
Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos");
Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows");
Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android");
var sep = Platform.pathSeparator;
Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\'));
final eol = Platform.lineTerminator;
Expect.isTrue(
(eol == '\n' && os != 'windows') || (eol == '\r\n' && os == 'windows'),
"unexpected line ending ${utf8.encode(eol)} on $os");
if (Platform.isWindows) {
Expect.equals("\r\n", Platform.lineTerminator, "windows lineTerminator");
Expect.equals("\\", Platform.pathSeparator, "$os path-seperator");
} else {
Expect.equals("\n", Platform.lineTerminator, "$os lineTerminator");
Expect.equals("/", Platform.pathSeparator, "$os path-seperator");
}
var hostname = Platform.localHostname;
Expect.isTrue(hostname is String && hostname != "");
var environment = Platform.environment;