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

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

Issue 23468027: Add FileSystemEntity.absolutePath and .isAbsolute properties. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change name to absolute, return type to File, Directory, and Link. Created 7 years, 3 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/link.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
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4 //
5 // Dart test program for testing FileSystemEntity.absolute
6
7 import "package:expect/expect.dart";
8 import 'dart:io';
9
10 main() {
11 if (Platform.isWindows) {
12 testWindows();
13 try {
14 Directory.current = 'C:\\';
15 } catch (e) {
16 return;
17 }
18 testWindows();
19 } else {
20 testPosix();
21 Directory.current = '.';
22 testPosix();
23 Directory.current = '/';
24 testPosix();
25
26 }
27 }
28
29 testWindows() {
30 String current = Directory.current.path;
31 for (String relative in ['abd', '..', '.', 'efg/hij', 'abc/']) {
32 if (current.endsWith('\\')) {
33 Expect.equals(new File(relative).absolute.path, '$current$relative');
34 } else {
35 Expect.equals(new File(relative).absolute.path, '$current\\$relative');
36 }
37 Expect.isTrue(new File(relative).absolute.isAbsolute);
38 }
39 for (String absolute in ['c:/abd', 'D:\\rf', '\\\\a_share\\folder',
40 '\\\\?\\c:\\prefixed\path\\']) {
41 Expect.isTrue(new File(absolute).absolute.path == absolute);
42 Expect.isTrue(new File(absolute).absolute.isAbsolute);
43 }
44 }
45
46 testPosix() {
47 String current = Directory.current.path;
48 print(Directory.current.path);
49 for (String relative in ['abd', '..', '.', 'efg/hij', 'abc/']) {
50 if (current.endsWith('/')) {
51 Expect.equals(new File(relative).absolute.path, '$current$relative');
52 } else {
53 Expect.equals(new File(relative).absolute.path, '$current/$relative');
54 }
55 Expect.isTrue(new File(relative).absolute.isAbsolute);
56 Expect.equals(new Directory(relative).absolute.path,
57 new Link(relative).absolute.path);
58 Expect.isTrue(new File(relative).absolute is File);
59 Expect.isTrue(new Directory(relative).absolute is Directory);
60 Expect.isTrue(new Link(relative).absolute is Link);
61 }
62 for (String absolute in ['/abd', '/', '/./..\\', '/efg/hij', '/abc/']) {
63 Expect.equals(new File(absolute).absolute.path, absolute);
64 Expect.isTrue(new File(absolute).absolute.isAbsolute);
65 }
66 }
OLDNEW
« no previous file with comments | « sdk/lib/io/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698