|
5 | 5 | end |
6 | 6 |
|
7 | 7 | properties (TestParameter) |
8 | | -base_relative_to |
9 | | -other_relative_to |
10 | | -ref_relative_to |
11 | | -ref_proximate_to |
| 8 | +p_relative_to |
| 9 | +p_proximate_to |
12 | 10 | in_is_absolute |
13 | 11 | ref_is_absolute |
14 | 12 | in_filename = {'', '/foo/bar/baz', '/foo/bar/baz/', 'foo/bar/baz.txt', 'foo/bar/baz.txt.gz'} |
|
20 | 18 | in_parent |
21 | 19 | ref_parent |
22 | 20 |
|
23 | | -in_join = {"", "a", "", "a/b/", "/", "", "a", "a//", "a/b/../", "a/b", "a/b", "ab/cd"} |
24 | | -other_join = {"", "", "b", "c/", "", "/", "b//", "b//", "c/d/../", "..", "c/d", "/ef"} |
25 | | -ref_join = {"", "a", "b", "a/b/c", "/", "/", "a/b", "a/b", "a/c", "a", "a/b/c/d", "/ef"} |
| 21 | +p_join = {{"", "", ""}, ... |
| 22 | +{"a", "", "a"}, ... |
| 23 | +{"", "a", "a"}, ... |
| 24 | +{"a/b/", "c/", "a/b/c"}, ... |
| 25 | +{"/", "", "/"}, ... |
| 26 | +{"", "/", "/"}, ... |
| 27 | +{"a", "b//", "a/b"}, ... |
| 28 | +{"a//", "b//", "a/b"}, ... |
| 29 | +{"a/b/../", "c/d/../", "a/c"}, ... |
| 30 | +{"a/b", "..", "a"}, ... |
| 31 | +{"a/b", "c/d", "a/b/c/d"}, ... |
| 32 | +{"ab/cd", "/ef", "/ef"} ... |
| 33 | +}; |
26 | 34 |
|
27 | 35 | in_suffix = {"", "/foo/bar/baz", "/foo/bar/baz/", "foo/bar/baz.txt", "foo/bar/baz.txt.gz", ".stat", ".stat.txt"} |
28 | 36 | ref_suffix = {"", "", "", ".txt", ".gz", ".stat", ".txt"} |
29 | 37 |
|
30 | | -in_norm = {"", "//a/b/", "/a/b/", "a/b/", "a/../c", "a/b/../c", "a/b/../../c", "a/b/../../c/..", ... |
31 | | - "a/b/../../c/../..", "a////b"} |
32 | | -ref_norm = {".", "/a/b", "/a/b", "a/b", "c", "a/c", "c", ".", ... |
33 | | - "..", "a/b"} |
| 38 | +in_norm = {"", "a/..", "//a/b/", "/a/b/", "a/b/", "a/../c", "a/b/../c", "a/b/../../c", "a/b/../../c/..", ... |
| 39 | + "a/b/../../c/../..", "a////b", ".a", "..a", "a.", "a..", "./a/.", "../a"} |
| 40 | +ref_norm = {".", ".", "/a/b", "/a/b", "a/b", "c", "a/c", "c", ".", ... |
| 41 | + "..", "a/b", ".a", "..a", "a.", "a..", "a", "../a"} |
34 | 42 |
|
35 | 43 | in_root |
36 | 44 | ref_root |
|
41 | 49 | end |
42 | 50 |
|
43 | 51 | methods (TestParameterDefinition, Static) |
44 | | -function [base_relative_to, other_relative_to, ref_relative_to, ref_proximate_to, in_root, ref_root, in_parent, ref_parent] = init_relative_to(classToTest) %#ok<INUSD> |
| 52 | +function [p_relative_to, p_proximate_to, in_root, ref_root, in_parent, ref_parent] = init_relative_to(classToTest) %#ok<INUSD> |
45 | 53 |
|
46 | 54 | in_root = {"", "a/b", "./a/b", "../a/b", "/etc", "c:/etc"}; |
47 | 55 | ref_root = {"", "", "", "", "/", ""}; |
48 | 56 |
|
49 | 57 | in_parent = {"", ".", "..", "../..", "a/", "a/b", "a/b/", "ab/.parent", "ab/.parent.txt", "a/b/../.parent.txt", "a/////b////c", "c:/", "c:\", "c:/a/b", "c:\a/b"}; |
50 | 58 | ref_parent = {".", ".", ".", "..", ".", "a", "a", "ab", "ab", "a/b/..", "a/b", ".", ".", "c:/a", "c:\a"}; |
51 | 59 |
|
| 60 | +p_relative_to = {{'', '', '.'}, ... |
| 61 | +{'Hello', 'Hello', '.'}, ... |
| 62 | +{'Hello', 'Hello/', '.'}, ... |
| 63 | +{'./this/one', './this/two', '../two'}, ... |
| 64 | +{'/path/same', '/path/same/hi/..', '.'}, ... |
| 65 | +{'', '/', ''}, ... |
| 66 | +{'/', '', ''}, ... |
| 67 | +{'/', '/', '.'}, ... |
| 68 | +{'/dev/null', '/dev/null', '.'}, ... |
| 69 | +{'/a/b', 'c', ''}, ... |
| 70 | +{'c', '/a/b', ''}, ... |
| 71 | +{'/a/b', '/a/b', '.'}, ... |
| 72 | +{'/a/b', '/a', '..'}, ... |
| 73 | +{'/a/b/c/d', '/a/b', '../..'}, ... |
| 74 | +{'/this/one', '/this/two', '../two'}, ... |
| 75 | +{'/path/same', '/path/same/hi/..', '.'}}; |
| 76 | + |
| 77 | +p_proximate_to = p_relative_to; |
| 78 | + |
| 79 | +p_proximate_to{6}{3} = '/'; |
| 80 | +p_proximate_to{10}{3} = 'c'; |
| 81 | +p_proximate_to{11}{3} = '/a/b'; |
| 82 | + |
52 | 83 | if ispc |
53 | 84 |
|
54 | | -base_relative_to = {'', 'Hello', 'Hello', ... |
55 | | -'c:\a\b', 'c:\', 'c:/a/b', 'c:/a/b', 'c:\a/b\c/d', 'c:/path'}; |
| 85 | +p_relative_to = [p_relative_to, ... |
| 86 | +{{'c:\a\b', 'c:/', '../..'}, ... |
| 87 | +{'c:\', 'c:/a/b', 'a/b'}, ... |
| 88 | +{'c:/a/b', 'c:/a/b', '.'}, ... |
| 89 | +{'c:/a/b', 'c:/a', '..'}, ... |
| 90 | +{'c:\a/b\c/d', 'c:/a\b', '../..'}, ... |
| 91 | +{'c:/path', 'd:/path', ''}}]; |
56 | 92 |
|
57 | | -other_relative_to = {'', 'Hello', 'Hello/', ... |
58 | | -'c:/', 'c:/a/b', 'c:/a/b', 'c:/a', 'c:/a\b', 'd:/path'}; |
| 93 | +p_proximate_to = p_relative_to; |
59 | 94 |
|
60 | | -ref_relative_to = {'.', '.', '.', '../..', 'a/b', '.', '..', '../..', ''}; |
| 95 | +p_proximate_to{6}{3} = '/'; |
| 96 | +p_proximate_to{10}{3} = 'c'; |
| 97 | +p_proximate_to{11}{3} = '/a/b'; |
61 | 98 |
|
62 | | -ref_proximate_to = ref_relative_to; |
63 | | -ref_proximate_to{end} = other_relative_to{end}; |
| 99 | +p_proximate_to{end}{3} = "d:/path"; |
64 | 100 |
|
65 | 101 | ref_parent{12} = "c:/"; |
66 | 102 | ref_parent{13} = "c:/"; |
|
70 | 106 | ref_root{5} = ""; |
71 | 107 | ref_root{6} = "c:/"; |
72 | 108 |
|
73 | | -else |
74 | | - |
75 | | -base_relative_to = {'', '', '/', '/', 'Hello', 'Hello', '/dev/null', '/a/b', 'c', ... |
76 | | -'/a/b', '/a/b', '/a/b/c/d', '/this/one', '/path/same'}; |
77 | | - |
78 | | -other_relative_to = {'', '/', '', '/', 'Hello', 'Hello/', '/dev/null', 'c', '/a/b', ... |
79 | | -'/a/b', '/a', '/a/b', '/this/two', '/path/same/hi/..'}; |
80 | | - |
81 | | -ref_relative_to = {'.', '', '', '.', '.', '.', '.', '', '', ... |
82 | | -'.', '..', '../..', '../two', '.'}; |
83 | | - |
84 | | -ref_proximate_to = ref_relative_to; |
85 | | -ref_proximate_to{2} = '/'; |
86 | | -ref_proximate_to{8} = 'c'; |
87 | | -ref_proximate_to{9} = '/a/b'; |
88 | | - |
89 | | -end |
90 | | - |
91 | | -base_relative_to{end+1} = './this/one'; |
92 | | -other_relative_to{end+1} = './this/two'; |
93 | | -ref_relative_to{end+1} = '../two'; |
94 | | -ref_proximate_to{end+1} = ref_relative_to{end}; |
| 109 | +end % if ispc |
95 | 110 |
|
96 | 111 | end |
97 | 112 |
|
@@ -170,8 +185,8 @@ function test_posix(tc) |
170 | 185 | end |
171 | 186 |
|
172 | 187 |
|
173 | | -function test_join(tc, in_join, other_join, ref_join) |
174 | | -tc.verifyEqual(stdlib.join(in_join, other_join), ref_join) |
| 188 | +function test_join(tc, p_join) |
| 189 | +tc.verifyEqual(stdlib.join(p_join{1}, p_join{2}), p_join{3}) |
175 | 190 | end |
176 | 191 |
|
177 | 192 |
|
@@ -236,15 +251,15 @@ function test_with_suffix(tc) |
236 | 251 | end |
237 | 252 |
|
238 | 253 |
|
239 | | -function test_relative_to(tc, base_relative_to, other_relative_to, ref_relative_to) |
| 254 | +function test_relative_to(tc, p_relative_to) |
240 | 255 | tc.assumeTrue(stdlib.has_java) |
241 | | -tc.verifyEqual(stdlib.relative_to(base_relative_to, other_relative_to), string(ref_relative_to)) |
| 256 | +tc.verifyEqual(stdlib.relative_to(p_relative_to{1}, p_relative_to{2}), string(p_relative_to{3})) |
242 | 257 | end |
243 | 258 |
|
244 | 259 |
|
245 | | -function test_proximate_to(tc, base_relative_to, other_relative_to, ref_proximate_to) |
| 260 | +function test_proximate_to(tc, p_proximate_to) |
246 | 261 | tc.assumeTrue(stdlib.has_java) |
247 | | -tc.verifyEqual(stdlib.proximate_to(base_relative_to, other_relative_to), string(ref_proximate_to)) |
| 262 | +tc.verifyEqual(stdlib.proximate_to(p_proximate_to{1}, p_proximate_to{2}), string(p_proximate_to{3})) |
248 | 263 | end |
249 | 264 |
|
250 | 265 |
|
|
0 commit comments