view test/bug-53599.tst @ 31002:c05aa021e971 stable

memory.m: Redo documentation to be formatted correctly in Info output. * memory.m: Don't use @var macro on items which are not variables. Add "Example" labels to example code. Indent Octave output in @example blocks so it is exactly what a user would see.
author Rik <rik@octave.org>
date Sun, 15 May 2022 18:06:02 -0700
parents 9080316864bf
children 332a6ccac881
line wrap: on
line source

%!function rval = sggval (val)
%!  global gval
%!  if (nargin == 1)
%!    gval = val;
%!  else
%!    rval = gval;
%!  endif
%!endfunction

%!test <*53599>
%! global gval
%! assert (isempty (gval))
%! sggval (13);
%! assert (sggval (), 13);
%! assert (gval, 13);
%! clear global gval
%! assert (sggval (), [])
%! gval = 42;
%! assert (sggval (), []);
%! clear gval
%! global gval
%! gval = 42;
%! assert (sggval (), 42);
%! clear -global gval;  # cleanup after test