Mercurial > hg > octave-nkf
comparison scripts/io/is_valid_file_id.m @ 11144:461ae8d58cdb
tests for is_valid_file_id
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 23 Oct 2010 02:04:51 -0400 |
parents | 3450551f591e |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
11143:195cffc2d0a3 | 11144:461ae8d58cdb |
---|---|
26 | 26 |
27 retval = false; | 27 retval = false; |
28 | 28 |
29 if (nargin == 1) | 29 if (nargin == 1) |
30 try | 30 try |
31 [file, mode, arch] = fopen (fid); | 31 if (isscalar (fid)) |
32 retval = ! isempty (file); | 32 [file, mode, arch] = fopen (fid); |
33 retval = ! isempty (file); | |
34 endif | |
33 end_try_catch | 35 end_try_catch |
34 else | 36 else |
35 print_usage (); | 37 print_usage (); |
36 endif | 38 endif |
37 | 39 |
38 endfunction | 40 endfunction |
41 | |
42 %!assert (is_valid_file_id (stdout)) | |
43 %!assert (! is_valid_file_id ([1,2;3,4])) | |
44 %!assert (! is_valid_file_id ("not_a_file_id")) | |
45 %!assert (! is_valid_file_id (-1)) | |
46 %!assert (! is_valid_file_id (pi)) |