# HG changeset patch # User Michael Goffioul # Date 1207761847 14400 # Node ID 30564b8b19f5745e33209df3d9e846a8eb27b112 # Parent e9b9f74e028911eb6e6f99726fca5413f689f4fc Fix various tests under Win32. diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-09 Michael Goffioul + + * DLD-FUNCTIONS/dispatch.cc: Replace system("echo '...'>...") calls + with real file writing. + 2008-04-07 Jaroslav Hajek * DLD-FUNCTIONS/qr.cc (Fqrshift): New function. diff --git a/src/DLD-FUNCTIONS/dispatch.cc b/src/DLD-FUNCTIONS/dispatch.cc --- a/src/DLD-FUNCTIONS/dispatch.cc +++ b/src/DLD-FUNCTIONS/dispatch.cc @@ -230,13 +230,21 @@ FIXME I would rather not create dispatch_x/dispatch_y in the current directory! I don't want them installed accidentally. +%!function echo_to_file (str, name) +%! fid = fopen (name, 'w'); +%! if (fid != -1) +%! fprintf (fid, str); +%! fprintf (fid, '\n'); +%! fclose (fid); +%! endif + %!test # replace base m-file -%! system("echo 'function a=dispatch_x(a)'>dispatch_x.m"); +%! echo_to_file ('function a=dispatch_x(a)', "dispatch_x.m"); %! dispatch('dispatch_x','length','string') %! assert(dispatch_x(3),3) %! assert(dispatch_x("a"),1) %! sleep (2); -%! system("echo 'function a=dispatch_x(a),++a;'>dispatch_x.m"); +%! echo_to_file ('function a=dispatch_x(a),++a;', "dispatch_x.m"); %! rehash(); %! assert(dispatch_x(3),4) %! assert(dispatch_x("a"),1) @@ -244,11 +252,11 @@ %! unlink("dispatch_x.m"); %!test # replace dispatch m-file -%! system("echo 'function a=dispatch_y(a)'>dispatch_y.m"); +%! echo_to_file ('function a=dispatch_y(a)', "dispatch_y.m"); %! dispatch('hello','dispatch_y','complex scalar') %! assert(hello(3i),3i) %! sleep (2); -%! system("echo 'function a=dispatch_y(a),++a;'>dispatch_y.m"); +%! echo_to_file ('function a=dispatch_y(a),++a;', "dispatch_y.m"); %! rehash(); %! assert(hello(3i),1+3i) %!test diff --git a/test/ChangeLog b/test/ChangeLog --- a/test/ChangeLog +++ b/test/ChangeLog @@ -23,6 +23,13 @@ which work on dimensions alone (squeeze, triu, etc.) work for all objects and preserve type. +2008-04-09 Michael Goffioul + + * test_string.m: Fix isprint test under Win32, where + isprint(setstr(9)) is true. + * test_system.m: Add condition for various syscall tests. Make cd test + able to deal with drive-letter-only pathnames (e.g. C:\) under Win32. + 2008-03-07 John W. Eaton * test_logical-wfi-t.m, test_logical-wfi-f.m: Update tests for diff --git a/test/test_string.m b/test/test_string.m --- a/test/test_string.m +++ b/test/test_string.m @@ -369,6 +369,9 @@ %! result = zeros (1, 128); %! %! result (33:127) = 1; +%! if (ispc () && ! isunix ()) +%! result(10) = 1; +%! endif %! %! assert(all (isprint (charset) == result)); diff --git a/test/test_system.m b/test/test_system.m --- a/test/test_system.m +++ b/test/test_system.m @@ -253,7 +253,7 @@ %!error file_in_path ("foo", "bar", "baz", "ooka"); %% test/octave.test/system/tilde_expand-1.m -%!test +%!testif HAVE_GETPWUID %! x = getpwuid (getuid ()); %! assert((strcmp (x.dir, tilde_expand ("~")) %! && strcmp (x.dir, tilde_expand (sprintf ("~%s", x.name))) @@ -266,7 +266,8 @@ %!error tilde_expand ("str", 2); %% test/octave.test/system/getpgrp-1.m -%!assert(getpgrp () > 0); +%!testif HAVE_GETPGRP +%! assert(getpgrp () > 0); %% test/octave.test/system/getpgrp-2.m %!error <... getpgrp> getpgrp (1); @@ -278,7 +279,8 @@ %!error <... getpid> getpid (1); %% test/octave.test/system/getppid-1.m -%!assert(getppid () > 0); +%!testif HAVE_GETPPID +%! assert(getppid () > 0); %% test/octave.test/system/getppid-2.m %!error <... getppid> getppid (1); @@ -347,7 +349,14 @@ %! cd / %! d1 = pwd (); %! cd (xdir); -%! assert("/", d1); +%! if (ispc () && ! isunix ()) +%! # should be a drive letter +%! assert(length (d1), 3); +%! assert(d1(2), ":"); +%! assert(d1(3), "\\"); +%! else +%! assert("/", d1); +%! endif %! assert(pwd(), xdir); %% test/octave.test/system/cd-2.m @@ -357,7 +366,7 @@ %!assert(isstr (pwd ())); %% test/octave.test/system/getpwent-1.m -%!test +%!testif HAVE_GETPWENT %! s = getpwent (); %! endpwent (); %! assert((isstruct (s) @@ -373,7 +382,7 @@ %!error getpwent (1); %% test/octave.test/system/getpwuid-1.m -%!test +%!testif HAVE_GETPWUID %! x = getpwent (); %! y = getpwuid (x.uid); %! endpwent (); @@ -386,7 +395,7 @@ %!error getpwuid (1, 2); %% test/octave.test/system/getpwnam-1.m -%!test +%!testif HAVE_GETPWNAM %! x = getpwent (); %! y = getpwnam (x.name); %! endpwent (); @@ -399,7 +408,7 @@ %!error getpwnam ("foo", 1); %% test/octave.test/system/setpwent-1.m -%!test +%!testif HAVE_SETPWENT %! x = getpwent (); %! setpwent (); %! y = getpwent (); @@ -413,7 +422,7 @@ %!error endpwent (1); %% test/octave.test/system/getgrent-1.m -%!test +%!testif HAVE_GETGRENT %! x = getgrent (); %! endgrent (); %! assert((isstruct (x) @@ -426,7 +435,7 @@ %!error getgrent (1); %% test/octave.test/system/getgrgid-1.m -%!test +%!testif HAVE_GETGRGID %! x = getgrent (); %! y = getgrgid (x.gid); %! endgrent (); @@ -439,7 +448,7 @@ %!error getgrgid (1, 2); %% test/octave.test/system/getgrnam-1.m -%!test +%!testif HAVE_GETGRNAM %! x = getgrent (); %! y = getgrnam (x.name); %! endgrent (); @@ -452,7 +461,7 @@ %!error getgrnam ("foo", 1); %% test/octave.test/system/setgrent-1.m -%!test +%!testif HAVE_SETGRENT %! x = getgrent (); %! setgrent (); %! y = getgrent ();