Skip to content

Commit 9120436

Browse files
committed
test symlink bc
1 parent c66075c commit 9120436

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

+stdlib/create_symlink.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
% For example, Matlab 25.1.0.2973910 R2025a Update 1 gave this error.
1212

1313
function [i, b] = create_symlink(target, link, backend)
14-
arguments
15-
target
16-
link
17-
backend (1,:) string = ["native", "dotnet", "python", "sys"]
14+
if nargin < 3
15+
backend = ["native", "dotnet", "python", "sys"];
16+
else
17+
backend = string(backend);
1818
end
1919

2020
i = logical.empty;

+stdlib/is_symlink.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
% * b: backend used
99

1010
function [i, b] = is_symlink(file, backend)
11-
arguments
12-
file
13-
backend (1,:) string = ["native", "java", "python", "dotnet", "sys"]
11+
if nargin < 2
12+
backend = ["native", "java", "python", "dotnet", "sys"];
13+
else
14+
backend = string(backend);
1415
end
1516

1617
i = logical.empty;

+stdlib/read_symlink.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
% * b: backend used
1212

1313
function [r, b] = read_symlink(file, backend)
14-
arguments
15-
file
16-
backend (1,:) string = ["native", "java", "dotnet", "python", "sys"]
14+
if nargin < 2
15+
backend = ["native", "java", "python", "dotnet", "sys"];
16+
else
17+
backend = string(backend);
1718
end
1819

1920

test/TestSymlink.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2019b', 'symlink', 'impure'}) ...
2+
TestTags = {'R2017b', 'symlink'}) ...
33
TestSymlink < matlab.unittest.TestCase
44

55
properties
@@ -21,13 +21,14 @@
2121
% needs to be per-method because multiple functions are used to make the same files
2222

2323
function setup_symlink(tc)
24-
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture())
24+
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture());
2525

26-
tc.link = fullfile(pwd(), 'my.lnk');
26+
tc.link = [pwd(), '/my.lnk'];
2727

28-
tc.target = stdlib.append(mfilename("fullpath"), '.m');
28+
tc.target = [pwd(), '/my_target.txt'];
29+
tc.assertTrue(stdlib.touch(tc.target), "failed to create test target " + tc.target)
2930

30-
tc.assumeTrue(stdlib.create_symlink(tc.target, tc.link), ...
31+
tc.assertTrue(stdlib.create_symlink(tc.target, tc.link), ...
3132
"failed to create test link " + tc.link)
3233
end
3334
end
@@ -75,7 +76,7 @@ function test_create_symlink(tc, B_create_symlink)
7576
tc.applyFixture(matlab.unittest.fixtures.SuppressedWarningsFixture(["MATLAB:io:filesystem:symlink:TargetNotFound","MATLAB:io:filesystem:symlink:FileExists"]))
7677

7778
ano = fullfile(pwd(), 'another.lnk');
78-
tc.assertThat(ano, ~matlab.unittest.constraints.IsFile)
79+
tc.assertFalse(isfile(ano))
7980
tc.assertFalse(stdlib.is_symlink(ano))
8081

8182
r = stdlib.create_symlink(tc.target, ano, B_create_symlink);

0 commit comments

Comments
 (0)