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

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

Issue 10668041: Make Path implement (extend) Hashable, and make Path.append to an empty path work right. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests. Created 8 years, 6 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();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 testJoin('a/b/c', '../../d/', 'a/d/'); 150 testJoin('a/b/c', '../../d/', 'a/d/');
151 151
152 void testAppend(String a, String b, String c) { 152 void testAppend(String a, String b, String c) {
153 Expect.equals(new Path(a).append(b).toString(), c); 153 Expect.equals(new Path(a).append(b).toString(), c);
154 } 154 }
155 155
156 testAppend('/a/b', 'c', '/a/b/c'); 156 testAppend('/a/b', 'c', '/a/b/c');
157 testAppend('a/b/', 'cd', 'a/b/cd'); 157 testAppend('a/b/', 'cd', 'a/b/cd');
158 testAppend('.', '..', './..'); 158 testAppend('.', '..', './..');
159 testAppend('a/b', '/c/d', 'a/b//c/d'); 159 testAppend('a/b', '/c/d', 'a/b//c/d');
160 testAppend('', 'foo/bar', 'foo/bar');
161 testAppend('/foo', '', '/foo/');
160 162
161 // .join can only join a relative path to a path. 163 // .join can only join a relative path to a path.
162 // It cannot join an absolute path to a path. 164 // It cannot join an absolute path to a path.
163 Expect.throws(() => new Path('/a/b/').join(new Path('/c/d'))); 165 Expect.throws(() => new Path('/a/b/').join(new Path('/c/d')));
164 166
165 // Test Path.relativeTo. 167 // Test Path.relativeTo.
166 Expect.equals('c/d', 168 Expect.equals('c/d',
167 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());
168 Expect.equals('c/d', 170 Expect.equals('c/d',
169 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());
170 Expect.equals('.', 172 Expect.equals('.',
171 new Path('/a').relativeTo(new Path('/a')).toString()); 173 new Path('/a').relativeTo(new Path('/a')).toString());
172 174
173 // Not implemented yet. Should return new Path('../b/c/d/'). 175 // Not implemented yet. Should return new Path('../b/c/d/').
174 Expect.throws(() => 176 Expect.throws(() =>
175 new Path('b/c/d/').relativeTo(new Path('a/'))); 177 new Path('b/c/d/').relativeTo(new Path('a/')));
176 // Should always throw - no relative path can be constructed. 178 // Should always throw - no relative path can be constructed.
177 Expect.throws(() => 179 Expect.throws(() =>
178 new Path('a/b').relativeTo(new Path('../../d'))); 180 new Path('a/b').relativeTo(new Path('../../d')));
179 } 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