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

Side by Side Diff: tests/standalone/io/path_test.dart

Issue 11096026: Revert "Improving relative path support." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « runtime/bin/path_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 // Test the Path class in dart:io. 5 // Test the Path class in dart:io.
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 8
9 void main() { 9 void main() {
10 testBaseFunctions(); 10 testBaseFunctions();
11 testCanonicalize(); 11 testCanonicalize();
12 testJoinAppend(); 12 testJoinAppend();
13 testRelativeTo();
14 } 13 }
15 14
16 void testBaseFunctions() { 15 void testBaseFunctions() {
17 testGetters(new Path("/foo/bar/fisk.hest"), 16 testGetters(new Path("/foo/bar/fisk.hest"),
18 ['/foo/bar', 'fisk.hest', 'fisk', 'hest'], 17 ['/foo/bar', 'fisk.hest', 'fisk', 'hest'],
19 'absolute canonical'); 18 'absolute canonical');
20 testGetters(new Path(''), 19 testGetters(new Path(''),
21 ['', '', '', ''], 20 ['', '', '', ''],
22 'empty'); 21 'empty');
23 // This corner case leaves a trailing slash for the root. 22 // This corner case leaves a trailing slash for the root.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 testAppend('/a/b', 'c', '/a/b/c'); 156 testAppend('/a/b', 'c', '/a/b/c');
158 testAppend('a/b/', 'cd', 'a/b/cd'); 157 testAppend('a/b/', 'cd', 'a/b/cd');
159 testAppend('.', '..', './..'); 158 testAppend('.', '..', './..');
160 testAppend('a/b', '/c/d', 'a/b//c/d'); 159 testAppend('a/b', '/c/d', 'a/b//c/d');
161 testAppend('', 'foo/bar', 'foo/bar'); 160 testAppend('', 'foo/bar', 'foo/bar');
162 testAppend('/foo', '', '/foo/'); 161 testAppend('/foo', '', '/foo/');
163 162
164 // .join can only join a relative path to a path. 163 // .join can only join a relative path to a path.
165 // It cannot join an absolute path to a path. 164 // It cannot join an absolute path to a path.
166 Expect.throws(() => new Path('/a/b/').join(new Path('/c/d'))); 165 Expect.throws(() => new Path('/a/b/').join(new Path('/c/d')));
167 }
168 166
169 void testRelativeTo() { 167 // Test Path.relativeTo.
170 Expect.equals('c/d', 168 Expect.equals('c/d',
171 new Path('/a/b/c/d').relativeTo(new Path('/a/b')).toString()); 169 new Path('/a/b/c/d').relativeTo(new Path('/a/b')).toString());
172 Expect.equals('c/d', 170 Expect.equals('c/d',
173 new Path('/a/b/c/d').relativeTo(new Path('/a/b/')).toString()); 171 new Path('/a/b/c/d').relativeTo(new Path('/a/b/')).toString());
174 Expect.equals('.', 172 Expect.equals('.',
175 new Path('/a').relativeTo(new Path('/a')).toString()); 173 new Path('/a').relativeTo(new Path('/a')).toString());
176 174
177 // Trailing / in base path represents directory
178 Expect.equals('../../z/x/y',
179 new Path('/a/b/z/x/y').relativeTo(new Path('/a/b/c/d/')).toString());
180 Expect.equals('../z/x/y',
181 new Path('/a/b/z/x/y').relativeTo(new Path('/a/b/c/d')).toString());
182 Expect.equals('../z/x/y/',
183 new Path('/a/b/z/x/y/').relativeTo(new Path('/a/b/c/d')).toString());
184
185 Expect.equals('../../z/x/y',
186 new Path('/z/x/y').relativeTo(new Path('/a/b/c')).toString());
187 Expect.equals('../../../z/x/y',
188 new Path('/z/x/y').relativeTo(new Path('/a/b/c/')).toString());
189
190 // Not implemented yet. Should return new Path('../b/c/d/'). 175 // Not implemented yet. Should return new Path('../b/c/d/').
191 Expect.throws(() => 176 Expect.throws(() =>
192 new Path('b/c/d/').relativeTo(new Path('a/'))); 177 new Path('b/c/d/').relativeTo(new Path('a/')));
193 // Should always throw - no relative path can be constructed. 178 // Should always throw - no relative path can be constructed.
194 Expect.throws(() => 179 Expect.throws(() =>
195 new Path('a/b').relativeTo(new Path('../../d'))); 180 new Path('a/b').relativeTo(new Path('../../d')));
196 } 181 }
OLDNEW
« no previous file with comments | « runtime/bin/path_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698