File tree Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Original file line number Diff line number Diff line change 88end
99% need to have string array type for p(:)
1010
11+ p = p(: );
12+
13+ ok(size(p )) = false ;
14+
15+ i = isfile(p );
16+
17+ if ispc()
18+ pe = split(string(getenv(" PATHEXT" )), pathsep );
19+ i = i & endsWith(stdlib .suffix(p(i )), pe , ' IgnoreCase' , true );
20+ end
21+
22+ if ~any(i ), return , end
23+
24+
1125try
1226
1327 if isunix
1630 props = " Readable" ;
1731 end
1832
19- p = p(: );
20- i = isfile(p );
21- ok(size(p )) = false ;
22- if ~any(i ), return , end
23-
2433 t(i , : ) = getPermissions(filePermissions(p(i )), props );
2534
2635 ok(i ) = isfile(p(i )) & any(t{i ,: }, 2 );
2736
2837catch e
38+
2939 switch e .identifier
3040 case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
3141 a = file_attributes_legacy(p );
32- ok = isfile( p ) && ( a .UserExecute || a .GroupExecute || a .OtherExecute ) ;
42+ ok = a .UserExecute || a .GroupExecute || a .OtherExecute ;
3343 otherwise , rethrow(e )
3444 end
3545end
Original file line number Diff line number Diff line change 11classdef TestIsExe < matlab .unittest .TestCase
22
33properties (TestParameter )
4- p = {{" . " , false }}
4+ p = {{fileparts(mfilename( ' fullpath ' )) + " /../Readme.md " , false }}
55end
66
77methods (Test , TestTags = " impure" )
8+
89function test_is_exe(tc , p )
10+ tc .assumeThat(p{1 }, matlab .unittest .constraints .IsFile )
11+
912tc .verifyEqual(stdlib .is_exe(p{1 }), p{2 })
1013end
1114
15+
16+ function test_is_exe_dir(tc )
17+ tc .verifyFalse(stdlib .is_exe(' .' ))
18+ end
19+
20+
1221function test_matlab_exe(tc )
1322
1423f = fullfile(matlabroot , " bin/matlab" );
1524if ispc()
1625 f = f + " .exe" ;
1726end
1827
19- tc .verifyEqual (stdlib .is_exe(f ), true )
28+ tc .verifyTrue (stdlib .is_exe(f ))
2029end
2130
2231end
You can’t perform that action at this time.
0 commit comments