|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | 3 | // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
|
5 | | -import "package:expect/expect.dart"; |
6 | | - |
| 5 | +import 'package:test/test.dart'; |
7 | 6 | import 'package:front_end/src/fasta/util/relativize.dart'; |
8 | 7 |
|
9 | | -void testRelativize() { |
10 | | - void c(String expected, String base, String path, bool isWindows) { |
11 | | - if (isWindows == null) { |
12 | | - c(expected, base, path, true); |
13 | | - c(expected, base, path, false); |
14 | | - return; |
15 | | - } |
16 | | - |
17 | | - test(Uri base, Uri uri) { |
18 | | - String r = relativizeUri(base, uri, isWindows); |
19 | | - Uri resolved = base.resolve(r); |
20 | | - Expect.equals(uri.scheme.toLowerCase(), resolved.scheme.toLowerCase()); |
21 | | - if (isWindows) { |
22 | | - Expect.equals(uri.path.toLowerCase(), resolved.path.toLowerCase()); |
23 | | - } else { |
24 | | - Expect.equals(uri.path, resolved.path); |
| 8 | +void main() { |
| 9 | + test('test relativeUri', () { |
| 10 | + void c(String expected, String base, String path, bool isWindows) { |
| 11 | + if (isWindows == null) { |
| 12 | + c(expected, base, path, true); |
| 13 | + c(expected, base, path, false); |
| 14 | + return; |
25 | 15 | } |
26 | | - Expect.stringEquals(expected, r); |
27 | | - } |
28 | 16 |
|
29 | | - test(Uri.parse('file:$base'), Uri.parse('file:$path')); |
| 17 | + test(Uri base, Uri uri) { |
| 18 | + String r = relativizeUri(base, uri, isWindows); |
| 19 | + Uri resolved = base.resolve(r); |
| 20 | + expect(resolved.scheme.toLowerCase(), uri.scheme.toLowerCase()); |
| 21 | + if (isWindows) { |
| 22 | + expect(resolved.path.toLowerCase(), uri.path.toLowerCase()); |
| 23 | + } else { |
| 24 | + expect(resolved.path, uri.path); |
| 25 | + } |
| 26 | + expect(r, expected); |
| 27 | + } |
30 | 28 |
|
31 | | - test(Uri.parse('FILE:$base'), Uri.parse('FILE:$path')); |
| 29 | + test(Uri.parse('file:$base'), Uri.parse('file:$path')); |
32 | 30 |
|
33 | | - test(Uri.parse('file:$base'), Uri.parse('FILE:$path')); |
| 31 | + test(Uri.parse('FILE:$base'), Uri.parse('FILE:$path')); |
34 | 32 |
|
35 | | - test(Uri.parse('FILE:$base'), Uri.parse('file:$path')); |
36 | | - } |
| 33 | + test(Uri.parse('file:$base'), Uri.parse('FILE:$path')); |
37 | 34 |
|
38 | | - c('bar', '/', '/bar', null); |
39 | | - c('bar', '/foo', '/bar', null); |
40 | | - c('/bar', '/foo/', '/bar', null); |
| 35 | + test(Uri.parse('FILE:$base'), Uri.parse('file:$path')); |
| 36 | + } |
41 | 37 |
|
42 | | - c('bar', '///c:/', '///c:/bar', true); |
43 | | - c('bar', '///c:/foo', '///c:/bar', true); |
44 | | - c('/c:/bar', '///c:/foo/', '///c:/bar', true); |
| 38 | + c('bar', '/', '/bar', null); |
| 39 | + c('bar', '/foo', '/bar', null); |
| 40 | + c('/bar', '/foo/', '/bar', null); |
45 | 41 |
|
46 | | - c('BAR', '///c:/', '///c:/BAR', true); |
47 | | - c('BAR', '///c:/foo', '///c:/BAR', true); |
48 | | - c('/c:/BAR', '///c:/foo/', '///c:/BAR', true); |
| 42 | + c('bar', '///c:/', '///c:/bar', true); |
| 43 | + c('bar', '///c:/foo', '///c:/bar', true); |
| 44 | + c('/c:/bar', '///c:/foo/', '///c:/bar', true); |
49 | 45 |
|
50 | | - c( |
51 | | - '../sdk/lib/_internal/compiler/implementation/dart2js.dart', |
52 | | - '///C:/Users/person/dart_checkout_for_stuff/dart/ReleaseIA32/dart.exe', |
53 | | - '///c:/Users/person/dart_checkout_for_stuff/dart/sdk/lib/_internal/compiler/' |
54 | | - 'implementation/dart2js.dart', |
55 | | - true); |
| 46 | + c('BAR', '///c:/', '///c:/BAR', true); |
| 47 | + c('BAR', '///c:/foo', '///c:/BAR', true); |
| 48 | + c('/c:/BAR', '///c:/foo/', '///c:/BAR', true); |
56 | 49 |
|
57 | | - c('/Users/person/file.dart', '/users/person/', '/Users/person/file.dart', |
58 | | - false); |
| 50 | + c( |
| 51 | + '../sdk/lib/_internal/compiler/implementation/dart2js.dart', |
| 52 | + '///C:/Users/person/dart_checkout_for_stuff/dart/ReleaseIA32/dart.exe', |
| 53 | + '///c:/Users/person/dart_checkout_for_stuff/dart/sdk/lib/_internal/compiler/' |
| 54 | + 'implementation/dart2js.dart', |
| 55 | + true); |
59 | 56 |
|
60 | | - c('file.dart', '/Users/person/', '/Users/person/file.dart', null); |
| 57 | + c('/Users/person/file.dart', '/users/person/', '/Users/person/file.dart', |
| 58 | + false); |
61 | 59 |
|
62 | | - c('../person/file.dart', '/Users/other/', '/Users/person/file.dart', false); |
| 60 | + c('file.dart', '/Users/person/', '/Users/person/file.dart', null); |
63 | 61 |
|
64 | | - c('/Users/person/file.dart', '/Users/other/', '/Users/person/file.dart', |
65 | | - true); |
| 62 | + c('../person/file.dart', '/Users/other/', '/Users/person/file.dart', false); |
66 | 63 |
|
67 | | - c('out.js.map', '/Users/person/out.js', '/Users/person/out.js.map', null); |
| 64 | + c('/Users/person/file.dart', '/Users/other/', '/Users/person/file.dart', |
| 65 | + true); |
68 | 66 |
|
69 | | - c('../person/out.js.map', '/Users/other/out.js', '/Users/person/out.js.map', |
70 | | - false); |
| 67 | + c('out.js.map', '/Users/person/out.js', '/Users/person/out.js.map', null); |
71 | 68 |
|
72 | | - c('/Users/person/out.js.map', '/Users/other/out.js', |
73 | | - '/Users/person/out.js.map', true); |
| 69 | + c('../person/out.js.map', '/Users/other/out.js', '/Users/person/out.js.map', |
| 70 | + false); |
74 | 71 |
|
75 | | - c('out.js', '/Users/person/out.js.map', '/Users/person/out.js', null); |
| 72 | + c('/Users/person/out.js.map', '/Users/other/out.js', |
| 73 | + '/Users/person/out.js.map', true); |
76 | 74 |
|
77 | | - c('../person/out.js', '/Users/other/out.js.map', '/Users/person/out.js', |
78 | | - false); |
| 75 | + c('out.js', '/Users/person/out.js.map', '/Users/person/out.js', null); |
79 | 76 |
|
80 | | - c('/Users/person/out.js', '/Users/other/out.js.map', '/Users/person/out.js', |
81 | | - true); |
| 77 | + c('../person/out.js', '/Users/other/out.js.map', '/Users/person/out.js', |
| 78 | + false); |
82 | 79 |
|
83 | | - c('out.js', '/out.js.map', '/out.js', null); |
84 | | -} |
| 80 | + c('/Users/person/out.js', '/Users/other/out.js.map', '/Users/person/out.js', |
| 81 | + true); |
85 | 82 |
|
86 | | -void main() { |
87 | | - testRelativize(); |
| 83 | + c('out.js', '/out.js.map', '/out.js', null); |
| 84 | + }); |
88 | 85 | } |
0 commit comments