Skip to content

Commit f824994

Browse files
committed
join: correct java=true case
1 parent 033aa36 commit f824994

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

+stdlib/join.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
if stdlib.isoctave()
3333
p = javaObject("java.io.File", b).toPath().resolve(o).toString();
3434
elseif use_java
35-
p = java.io.File(b).toPath().resolve(o);
35+
p = string(java.io.File(b).toPath().resolve(o));
3636
else
3737

3838
if startsWith(o, "/") || (ispc && stdlib.is_absolute(o))
@@ -45,3 +45,9 @@
4545
end
4646

4747
end
48+
49+
%!assert(join("", ""), "")
50+
%!assert(join("", "b"), "b")
51+
%!assert(join("a", ""), "a")
52+
%!assert(join("a", "b"), "a/b")
53+
%!assert(join("a", "/b/c"), "/b/c")

test/TestFilePure.m

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
{"a/b/../", "c/d/../", "a/b/../c/d/.."}, ...
2727
{"a/b", "..", "a/b/.."}, ...
2828
{"a/b", "c/d", "a/b/c/d"}, ...
29-
{"ab/cd", "/ef", "/ef"} ...
29+
{"ab/cd", "/ef", "/ef"}, ...
30+
{test_homedir(), "", test_homedir()}, ...
31+
{matlabroot, "bin", stdlib.posix(matlabroot + "/bin")}
3032
}
3133

3234
p_suffix = {{"", ""}, {"/a/b/c", ""}, {"/a/b/c/", ""}, {"a/b/c.txt", ".txt"}, {"a/b/c.txt.gz", ".gz"}, {".stat", ".stat"}, {".stat.txt", ".txt"}}
@@ -87,31 +89,16 @@
8789

8890

8991
function [p_is_absolute] = init_is_absolute()
90-
9192
p_is_absolute = {{"", false}, {"x", false}, {"x:", false}, {"x:/foo", false}, {"/foo", true}};
92-
9393
if ispc
9494
p_is_absolute{4}{2} = true;
9595
p_is_absolute{5}{2} = false;
9696
end
97-
9897
end
9998

10099
end
101100

102101

103-
104-
methods (TestClassSetup)
105-
106-
function setup_path(tc)
107-
top = fullfile(fileparts(mfilename("fullpath")), "..");
108-
tc.applyFixture(matlab.unittest.fixtures.PathFixture(top))
109-
end
110-
111-
end
112-
113-
114-
115102
methods (Test)
116103

117104
function test_posix(tc)

0 commit comments

Comments
 (0)