| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 testGetters(new Path("a/b.c/."), | 49 testGetters(new Path("a/b.c/."), |
| 50 ['a/b.c', '.', '.', ''], | 50 ['a/b.c', '.', '.', ''], |
| 51 ''); | 51 ''); |
| 52 // '..' at the end of a path is not considered an extension. | 52 // '..' at the end of a path is not considered an extension. |
| 53 testGetters(new Path("a/bc/../.."), | 53 testGetters(new Path("a/bc/../.."), |
| 54 ['a/bc/..', '..', '..', ''], | 54 ['a/bc/..', '..', '..', ''], |
| 55 ''); | 55 ''); |
| 56 | 56 |
| 57 // Test the special path cleaning operations on the Windows platform. | 57 // Test the special path cleaning operations on the Windows platform. |
| 58 if (Platform.operatingSystem == 'windows') { | 58 if (Platform.operatingSystem == 'windows') { |
| 59 testGetters(new Path.fromNative(@"c:\foo\bar\fisk.hest"), | 59 testGetters(new Path.fromNative(r"c:\foo\bar\fisk.hest"), |
| 60 ['/c:/foo/bar', 'fisk.hest', 'fisk', 'hest'], | 60 ['/c:/foo/bar', 'fisk.hest', 'fisk', 'hest'], |
| 61 'absolute canonical'); | 61 'absolute canonical'); |
| 62 testGetters(new Path.fromNative("\\foo\\bar\\"), | 62 testGetters(new Path.fromNative("\\foo\\bar\\"), |
| 63 ['/foo/bar', '', '', ''], | 63 ['/foo/bar', '', '', ''], |
| 64 'absolute canonical trailing'); | 64 'absolute canonical trailing'); |
| 65 testGetters(new Path.fromNative("\\foo\\bar\\hest"), | 65 testGetters(new Path.fromNative("\\foo\\bar\\hest"), |
| 66 ['/foo/bar', 'hest', 'hest', ''], | 66 ['/foo/bar', 'hest', 'hest', ''], |
| 67 'absolute canonical'); | 67 'absolute canonical'); |
| 68 testGetters(new Path.fromNative(@"foo/bar\hest/.fisk"), | 68 testGetters(new Path.fromNative(r"foo/bar\hest/.fisk"), |
| 69 ['foo/bar/hest', '.fisk', '', 'fisk'], | 69 ['foo/bar/hest', '.fisk', '', 'fisk'], |
| 70 'canonical'); | 70 'canonical'); |
| 71 testGetters(new Path.fromNative(@"foo//bar\\hest/\/.fisk."), | 71 testGetters(new Path.fromNative(r"foo//bar\\hest/\/.fisk."), |
| 72 ['foo//bar//hest', '.fisk.', '.fisk', ''], | 72 ['foo//bar//hest', '.fisk.', '.fisk', ''], |
| 73 ''); | 73 ''); |
| 74 } else { | 74 } else { |
| 75 // Make sure that backslashes are uninterpreted on other platforms. | 75 // Make sure that backslashes are uninterpreted on other platforms. |
| 76 testGetters(new Path.fromNative(@"/foo\bar/bif/fisk.hest"), | 76 testGetters(new Path.fromNative(r"/foo\bar/bif/fisk.hest"), |
| 77 [@'/foo\bar/bif', 'fisk.hest', 'fisk', 'hest'], | 77 [@'/foo\bar/bif', 'fisk.hest', 'fisk', 'hest'], |
| 78 'absolute canonical'); | 78 'absolute canonical'); |
| 79 testGetters(new Path.fromNative(@"//foo\bar///bif////fisk.hest"), | 79 testGetters(new Path.fromNative(r"//foo\bar///bif////fisk.hest"), |
| 80 [@'//foo\bar///bif', 'fisk.hest', 'fisk', 'hest'], | 80 [@'//foo\bar///bif', 'fisk.hest', 'fisk', 'hest'], |
| 81 'absolute'); | 81 'absolute'); |
| 82 testGetters(new Path.fromNative(@"/foo\ bar/bif/gule\ fisk.hest"), | 82 testGetters(new Path.fromNative(r"/foo\ bar/bif/gule\ fisk.hest"), |
| 83 [@'/foo\ bar/bif', @'gule\ fisk.hest', @'gule\ fisk', 'hest'], | 83 [@'/foo\ bar/bif', @'gule\ fisk.hest', @'gule\ fisk', 'hest'], |
| 84 'absolute canonical'); | 84 'absolute canonical'); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 void testGetters(Path path, List components, String properties) { | 89 void testGetters(Path path, List components, String properties) { |
| 90 final int DIRNAME = 0; | 90 final int DIRNAME = 0; |
| 91 final int FILENAME = 1; | 91 final int FILENAME = 1; |
| 92 final int FILENAME_NO_EXTENSION = 2; | 92 final int FILENAME_NO_EXTENSION = 2; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 Expect.equals('.', | 172 Expect.equals('.', |
| 173 new Path('/a').relativeTo(new Path('/a')).toString()); | 173 new Path('/a').relativeTo(new Path('/a')).toString()); |
| 174 | 174 |
| 175 // Not implemented yet. Should return new Path('../b/c/d/'). | 175 // Not implemented yet. Should return new Path('../b/c/d/'). |
| 176 Expect.throws(() => | 176 Expect.throws(() => |
| 177 new Path('b/c/d/').relativeTo(new Path('a/'))); | 177 new Path('b/c/d/').relativeTo(new Path('a/'))); |
| 178 // Should always throw - no relative path can be constructed. | 178 // Should always throw - no relative path can be constructed. |
| 179 Expect.throws(() => | 179 Expect.throws(() => |
| 180 new Path('a/b').relativeTo(new Path('../../d'))); | 180 new Path('a/b').relativeTo(new Path('../../d'))); |
| 181 } | 181 } |
| OLD | NEW |