# HG changeset patch # User Rik # Date 1412101111 25200 # Node ID 6cf253a39fde1f5812e3f7e8335dbdd96b972942 # Parent 7bc6fa304f67f6ed2858a82b1ef1484ecdd1a9e6 recycle.m: Overhaul function. * recycle.m: Redo docstring. Put input validation first. Add more input validation BIST tests. diff -r 7bc6fa304f67 -r 6cf253a39fde scripts/miscellaneous/recycle.m --- a/scripts/miscellaneous/recycle.m Tue Sep 30 11:08:24 2014 -0700 +++ b/scripts/miscellaneous/recycle.m Tue Sep 30 11:18:31 2014 -0700 @@ -21,10 +21,14 @@ ## @deftypefnx {Function File} {@var{old_state} =} recycle (@var{new_state}) ## Query or set the preference for recycling deleted files. ## -## Recycling files, instead of permanently deleting them, is not currently -## implemented in Octave. To help avoid accidental data loss an error -## will be raised if an attempt is made to enable file recycling. -## @seealso{delete} +## When recycling is enabled, commands which would permanently erase files +## instead move them to a temporary location (such as the directory labeled +## Trash). +## +## Programming Note: This function is provided for Matlab compatibility, but +## recycling is not implemented in Octave. To help avoid accidental data loss +## an error will be raised if an attempt is made to enable file recycling. +## @seealso{delete, rmdir} ## @end deftypefn ## Author: jwe @@ -42,16 +46,16 @@ endif if (nargin == 1) - if (ischar (state)) - if (strcmpi (state, "on")) - error ("recycle: recycling files is not implemented"); - elseif (strcmpi (state, "off")) - current_state = "off"; - else - error ("recycle: invalid value of STATE = '%s'", state); - endif + if (! ischar (state)) + error ("recycle: STATE must be a character string"); + endif + + if (strcmpi (state, "on")) + error ("recycle: recycling files is not implemented"); + elseif (strcmpi (state, "off")) + current_state = "off"; else - error ("recycle: STATE must be a character string"); + error ("recycle: invalid value of STATE = '%s'", state); endif endif @@ -62,7 +66,8 @@ %! recycle ("off"); %! assert (recycle ("off"), "off"); -%!error recycle ("on") %!error recycle ("on", "and I mean it") %!error recycle (1) +%!error recycle ("on") +%!error recycle ("foobar")