Mercurial > octave-nkf
diff libinterp/corefcn/variables.cc @ 19950:85c5a81c6ddd
Rewrite BIST tests for exist to pass on Windows (bug #44445).
* variables.cc (Fexist): Rewrite tests for absolute and rooted files to not
rely on UNIX behavior.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 07 Mar 2015 17:29:06 -0800 |
parents | 17d647821d61 |
children | e51473fdb622 |
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc Sat Mar 07 07:45:15 2015 -0800 +++ b/libinterp/corefcn/variables.cc Sat Mar 07 17:29:06 2015 -0800 @@ -642,6 +642,26 @@ %!assert (exist ("print_usage", "file"), 2) %!assert (exist ("print_usage", "dir"), 0) +## Don't search path for rooted relative file names +%!assert (exist ("plot.m", "file"), 2); +%!assert (exist ("./plot.m", "file"), 0); +%!assert (exist ("./%nonexistentfile%", "file"), 0); +%!assert (exist ("%nonexistentfile%", "file"), 0); + +## Don't search path for absolute file names +%!test +%! tname = tempname (pwd ()); +%! unwind_protect +%! ## open/close file to create it, equivalent of touch +%! fid = fopen (tname, "w"); +%! fclose (fid); +%! [~, fname] = fileparts (tname); +%! assert (exist (fullfile (pwd (), fname), "file"), 2); +%! unwind_protect_cleanup +%! unlink (tname); +%! end_unwind_protect +%! assert (exist (fullfile (pwd (), "%nonexistentfile%"), "file"), 0); + %!testif HAVE_CHOLMOD %! assert (exist ("chol"), 3); %! assert (exist ("chol.oct"), 3); @@ -662,16 +682,6 @@ %!error <TYPE must be a string> exist ("a", 1) %!error <NAME must be a string> exist (1) -%!test -%! flist = dir (); -%! fname = flist(3).name; ## skip . and .. -%! assert (exist (fullfile (pwd (), fname), "file"), 2) -%! assert (exist (fullfile (pwd (), "nonexistentfile"), "file"), 0) - -%!assert (exist ("plot.m", "file"), 2); -%!assert (exist ("./plot.m", "file"), 0); -%!assert (exist ("./nonexistentfile", "file"), 0); -%!assert (exist ("nonexistentfile", "file"), 0); */ octave_value