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

Unified Diff: tests/standalone/io/path_test.dart

Issue 11878015: Default constructor for dart:io Path now handles native Windows paths. Path() now does the same as… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't change tools/version.dart until the binaries are updated. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/https_server_test.dart ('k') | tests/standalone/io/process_set_exit_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/path_test.dart
diff --git a/tests/standalone/io/path_test.dart b/tests/standalone/io/path_test.dart
index 0e20a07fab6d1b905cb4e8f91981de502560c46f..b6d1b9911525d2a804807c631280197fb924d8d3 100644
--- a/tests/standalone/io/path_test.dart
+++ b/tests/standalone/io/path_test.dart
@@ -8,6 +8,7 @@ import "dart:io";
void main() {
testBaseFunctions();
+ testRaw();
testCanonicalize();
testJoinAppend();
testRelativeTo();
@@ -58,30 +59,33 @@ void testBaseFunctions() {
// Test the special path cleaning operations on the Windows platform.
if (Platform.operatingSystem == 'windows') {
- testGetters(new Path.fromNative(r"c:\foo\bar\fisk.hest"),
+ testGetters(new Path(r"c:\foo\bar\fisk.hest"),
['/c:/foo/bar', 'fisk.hest', 'fisk', 'hest'],
'absolute canonical');
- testGetters(new Path.fromNative("\\foo\\bar\\"),
+ testGetters(new Path("\\foo\\bar\\"),
['/foo/bar', '', '', ''],
'absolute canonical trailing');
- testGetters(new Path.fromNative("\\foo\\bar\\hest"),
+ testGetters(new Path("\\foo\\bar\\hest"),
['/foo/bar', 'hest', 'hest', ''],
'absolute canonical');
- testGetters(new Path.fromNative(r"foo/bar\hest/.fisk"),
+ testGetters(new Path(r"foo/bar\hest/.fisk"),
['foo/bar/hest', '.fisk', '', 'fisk'],
'canonical');
- testGetters(new Path.fromNative(r"foo//bar\\hest/\/.fisk."),
+ testGetters(new Path(r"foo//bar\\hest/\/.fisk."),
['foo//bar//hest', '.fisk.', '.fisk', ''],
'');
} else {
// Make sure that backslashes are uninterpreted on other platforms.
- testGetters(new Path.fromNative(r"/foo\bar/bif/fisk.hest"),
+ testGetters(new Path(r"c:\foo\bar\fisk.hest"),
+ ['', r'c:\foo\bar\fisk.hest', r'c:\foo\bar\fisk', 'hest'],
+ 'canonical');
+ testGetters(new Path(r"/foo\bar/bif/fisk.hest"),
[r'/foo\bar/bif', 'fisk.hest', 'fisk', 'hest'],
'absolute canonical');
- testGetters(new Path.fromNative(r"//foo\bar///bif////fisk.hest"),
+ testGetters(new Path(r"//foo\bar///bif////fisk.hest"),
[r'//foo\bar///bif', 'fisk.hest', 'fisk', 'hest'],
'absolute');
- testGetters(new Path.fromNative(r"/foo\ bar/bif/gule\ fisk.hest"),
+ testGetters(new Path(r"/foo\ bar/bif/gule\ fisk.hest"),
[r'/foo\ bar/bif', r'gule\ fisk.hest', r'gule\ fisk', 'hest'],
'absolute canonical');
}
@@ -104,6 +108,12 @@ void testGetters(Path path, List components, String properties) {
Expect.equals(path.hasTrailingSeparator, properties.contains('trailing'));
}
+void testRaw() {
+ Expect.equals(new Path.raw('c:\\foo/bar bad').toString(), 'c:\\foo/bar bad');
+ Expect.equals(new Path.raw('').toString(), '');
+ Expect.equals(new Path.raw('\\bar\u2603\n.').toString(), '\\bar\u2603\n.');
+}
+
void testCanonicalize() {
Function t = (input, canonicalized) {
Expect.equals(canonicalized, new Path(input).canonicalize().toString());
@@ -129,8 +139,13 @@ void testCanonicalize() {
t('foo/bar/../../../joe/../..', '../..');
t('a/b/c/../../..d/./.e/f././', 'a/..d/.e/f./');
t('/%:/foo/../..', '/%:/');
- t('c:/foo/../../..', '..');
- t('c:/foo/../../bad/dad/./..', 'bad');
+ if (Platform.operatingSystem == 'windows') {
+ t('c:/foo/../../..', '/c:/');
+ t('c:/foo/../../bad/dad/./..', '/c:/bad');
+ } else {
+ t('c:/foo/../../..', '..');
+ t('c:/foo/../../bad/dad/./..', 'bad');
+ }
}
void testJoinAppend() {
@@ -201,7 +216,7 @@ void testRelativeTo() {
void testWindowsShare() {
// Windows share information only makes sense on Windows.
if (Platform.operatingSystem != 'windows') return;
- var path = new Path.fromNative(r'\\share\a\b\..\c');
+ var path = new Path(r'\\share\a\b\..\c');
Expect.isTrue(path.isAbsolute);
Expect.isTrue(path.isWindowsShare);
Expect.isFalse(path.hasTrailingSeparator);
« no previous file with comments | « tests/standalone/io/https_server_test.dart ('k') | tests/standalone/io/process_set_exit_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698