66end
77
88methods (TestClassSetup )
9- function java_required(tc )
10- tc .assumeTrue(stdlib .has_java())
9+ function mex_required(tc )
10+ import matlab .unittest .fixtures .CurrentFolderFixture
11+
12+ tc .applyFixture(CurrentFolderFixture(" .." ))
13+ % matlab exist() doesn't work for MEX detection with ".." leading path
14+
15+ tc .assumeEqual(exist(" +stdlib/relative_to" , " file" ), 3 )
16+ tc .assumeEqual(exist(" +stdlib/proximate_to" , " file" ), 3 )
1117end
1218end
1319
@@ -35,28 +41,30 @@ function test_proximate_to(tc, pp)
3541{" Hello" , " Hello/" , " ." }, ...
3642{" a/./b" , " a/b" , " ." }, ...
3743{" a/b" , " a/./b" , " ." }, ...
38- {" ./this/one" , " ./this/two" , " ../two" }, ...
39- {" /path/same" , " /path/same/hi/.." , " hi/.." }, ...
40- {" " , " /" , " " }, ...
41- {" /" , " " , " " }, ...
44+ {" ./a/b" , " ./a/c" , " ../c" }, ...
4245{" /" , " /" , " ." }, ...
43- {" /dev/null " , " /dev/null " , " ." }, ...
44- {" / a/b" , " c" , " " }, ...
45- {" c " , " /a/b " , " " }, ...
46- {" /a/b " , " / a/b" , " ." }, ...
47- {" / a/b" , " /a " , " . ." }, ...
48- {" / a/b/c/d " , " /a/b " , " ../.. " }, ...
49- { " this/one " , " this/two " , " ../two " } };
46+ {" a/b/c/d " , " a/b " , " ../. ." }, ...
47+ {" a/b" , " a/ c" , " ../c " }, ...
48+ {" a/b " , " c " , " ../../c " }, ...
49+ {" c " , " a/b" , " ../a/b " }, ...
50+ {" a/b" , " a/b " , " ." }, ...
51+ {" a/b" , " a " , " .." }
52+ };
5053% NOTE: ".." in relative_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc.
5154
5255if ispc
5356p = [p , ...
54- {{" c:\a\ b" , " c :/" , " ../.." }, ...
55- {" c:\ " , " c :/a/b" , " a/b" }, ...
57+ {{" C:/a/ b" , " C :/" , " ../.." }, ...
58+ {" C:/ " , " C :/a/b" , " a/b" }, ...
5659{" c:/a/b" , " c:/a/b" , " ." }, ...
5760{" c:/a/b" , " c:/a" , " .." }, ...
5861{" c:\a/b\c/d" , " c:/a\b" , " ../.." }, ...
59- {" c:/path" , " d:/path" , " " }}];
62+ {" C:/path" , " D:/path" , " " }}];
63+ % note: on Windows the drive letter should be uppercase!
64+ else
65+ p = [p , ...
66+ {{" " , " a" , " a" }, ...
67+ {" /dev/null" , " /dev/null" , " ." }}];
6068end
6169
6270end
@@ -66,18 +74,9 @@ function test_proximate_to(tc, pp)
6674
6775p = init_rel();
6876
69- p{8 }{3 } = " /" ;
70- p{12 }{3 } = " c" ;
71- p{13 }{3 } = " /a/b" ;
7277
7378if ispc
74- p{8 }{3 } = " /" ;
75- p{12 }{3 } = " c" ;
76- p{13 }{3 } = " /a/b" ;
77-
78- p{end }{3 } = " d:/path" ;
79+ p{end }{3 } = " D:/path" ;
7980end
8081
81- p{end + 1 } = {" file:///" , " file:///" , " " };
82-
8382end
0 commit comments