Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
19949:d9f6260cf20a | 19950:85c5a81c6ddd |
---|---|
640 %!assert (exist ("print_usage"), 2) | 640 %!assert (exist ("print_usage"), 2) |
641 %!assert (exist ("print_usage.m"), 2) | 641 %!assert (exist ("print_usage.m"), 2) |
642 %!assert (exist ("print_usage", "file"), 2) | 642 %!assert (exist ("print_usage", "file"), 2) |
643 %!assert (exist ("print_usage", "dir"), 0) | 643 %!assert (exist ("print_usage", "dir"), 0) |
644 | 644 |
645 ## Don't search path for rooted relative file names | |
646 %!assert (exist ("plot.m", "file"), 2); | |
647 %!assert (exist ("./plot.m", "file"), 0); | |
648 %!assert (exist ("./%nonexistentfile%", "file"), 0); | |
649 %!assert (exist ("%nonexistentfile%", "file"), 0); | |
650 | |
651 ## Don't search path for absolute file names | |
652 %!test | |
653 %! tname = tempname (pwd ()); | |
654 %! unwind_protect | |
655 %! ## open/close file to create it, equivalent of touch | |
656 %! fid = fopen (tname, "w"); | |
657 %! fclose (fid); | |
658 %! [~, fname] = fileparts (tname); | |
659 %! assert (exist (fullfile (pwd (), fname), "file"), 2); | |
660 %! unwind_protect_cleanup | |
661 %! unlink (tname); | |
662 %! end_unwind_protect | |
663 %! assert (exist (fullfile (pwd (), "%nonexistentfile%"), "file"), 0); | |
664 | |
645 %!testif HAVE_CHOLMOD | 665 %!testif HAVE_CHOLMOD |
646 %! assert (exist ("chol"), 3); | 666 %! assert (exist ("chol"), 3); |
647 %! assert (exist ("chol.oct"), 3); | 667 %! assert (exist ("chol.oct"), 3); |
648 %! assert (exist ("chol", "file"), 3); | 668 %! assert (exist ("chol", "file"), 3); |
649 %! assert (exist ("chol", "builtin"), 0); | 669 %! assert (exist ("chol", "builtin"), 0); |
660 %!error exist (1,2,3) | 680 %!error exist (1,2,3) |
661 %!warning <"class" type argument is not implemented> exist ("a", "class"); | 681 %!warning <"class" type argument is not implemented> exist ("a", "class"); |
662 %!error <TYPE must be a string> exist ("a", 1) | 682 %!error <TYPE must be a string> exist ("a", 1) |
663 %!error <NAME must be a string> exist (1) | 683 %!error <NAME must be a string> exist (1) |
664 | 684 |
665 %!test | |
666 %! flist = dir (); | |
667 %! fname = flist(3).name; ## skip . and .. | |
668 %! assert (exist (fullfile (pwd (), fname), "file"), 2) | |
669 %! assert (exist (fullfile (pwd (), "nonexistentfile"), "file"), 0) | |
670 | |
671 %!assert (exist ("plot.m", "file"), 2); | |
672 %!assert (exist ("./plot.m", "file"), 0); | |
673 %!assert (exist ("./nonexistentfile", "file"), 0); | |
674 %!assert (exist ("nonexistentfile", "file"), 0); | |
675 */ | 685 */ |
676 | 686 |
677 octave_value | 687 octave_value |
678 lookup_function_handle (const std::string& nm) | 688 lookup_function_handle (const std::string& nm) |
679 { | 689 { |