Skip to content

Commit 69c5bf7

Browse files
committed
TestWhich own class
1 parent 5767fe9 commit 69c5bf7

File tree

2 files changed

+54
-48
lines changed

2 files changed

+54
-48
lines changed

test/TestFileImpure.m

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -228,54 +228,6 @@ function test_samepath(tc, in_same, other_same, ref_same)
228228
tc.verifyEqual(stdlib.samepath(in_same, other_same), ref_same)
229229
end
230230

231-
%%
232-
function test_which_name(tc)
233-
234-
tc.verifyEmpty(stdlib.which(tempname))
235-
236-
if ispc
237-
n = "pwsh.exe";
238-
else
239-
n = "ls";
240-
end
241-
%% which: Matlab in environment variable PATH
242-
% MacOS Matlab does not source .zshrc so Matlab is not on internal Matlab PATH
243-
% Unix-like OS may have Matlab as alias which is not visible to
244-
% stdlib.which()
245-
% virus scanners may block stdlib.which("cmd.exe") on Windows
246-
tc.verifyNotEmpty(stdlib.which(n))
247-
248-
end
249-
250-
251-
function test_is_exe_which_fullpath(tc)
252-
import matlab.unittest.constraints.IsFile
253-
import matlab.unittest.constraints.EndsWithSubstring
254-
255-
tc.verifyFalse(stdlib.is_exe(""))
256-
tc.verifyFalse(stdlib.is_exe(tempname))
257-
258-
n = "matlab";
259-
%% is_exe test
260-
p = fullfile(matlabroot, "bin", n);
261-
if ispc
262-
fp = p + ".exe";
263-
else
264-
fp = p;
265-
end
266-
tc.verifyTrue(stdlib.is_exe(fp))
267-
%% which: test absolute path
268-
exe = stdlib.which(p);
269-
270-
if ispc
271-
tc.verifyThat(exe, EndsWithSubstring(".exe"))
272-
else
273-
tc.verifyThat(exe, ~EndsWithSubstring(".exe"))
274-
end
275-
tc.verifyThat(exe, IsFile)
276-
277-
end
278-
279231
function test_hash(tc)
280232
import matlab.unittest.constraints.IsFile
281233
import matlab.unittest.fixtures.TemporaryFolderFixture

test/TestWhich.m

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
classdef TestWhich < matlab.unittest.TestCase
2+
3+
methods (Test)
4+
5+
function test_which_name(tc)
6+
7+
tc.verifyEmpty(stdlib.which(tempname))
8+
9+
if ispc
10+
n = "pwsh.exe";
11+
else
12+
n = "ls";
13+
end
14+
%% which: Matlab in environment variable PATH
15+
% MacOS Matlab does not source .zshrc so Matlab is not on internal Matlab PATH
16+
% Unix-like OS may have Matlab as alias which is not visible to
17+
% stdlib.which()
18+
% virus scanners may block stdlib.which("cmd.exe") on Windows
19+
tc.verifyNotEmpty(stdlib.which(n))
20+
21+
end
22+
23+
24+
function test_is_exe_which_fullpath(tc)
25+
import matlab.unittest.constraints.IsFile
26+
import matlab.unittest.constraints.EndsWithSubstring
27+
28+
tc.verifyFalse(stdlib.is_exe(""))
29+
tc.verifyFalse(stdlib.is_exe(tempname))
30+
31+
n = "matlab";
32+
%% is_exe test
33+
p = fullfile(matlabroot, "bin", n);
34+
if ispc
35+
fp = p + ".exe";
36+
else
37+
fp = p;
38+
end
39+
tc.verifyTrue(stdlib.is_exe(fp))
40+
%% which: test absolute path
41+
exe = stdlib.which(p);
42+
43+
if ispc
44+
tc.verifyThat(exe, EndsWithSubstring(".exe"))
45+
else
46+
tc.verifyThat(exe, ~EndsWithSubstring(".exe"))
47+
end
48+
tc.verifyThat(exe, IsFile)
49+
50+
end
51+
52+
end
53+
54+
end

0 commit comments

Comments
 (0)