view test/bug-53027/bug-53027.tst @ 31204:a81fad5c9fef

idx_vector: Fix wrong length calculation (bug #62968). * liboctave/array/idx-vector.cc: Fix wrong calculation for m_len in (start, limit, step) constructor to account for incomplete intervals. * liboctave/array/idx-vector.h: Add comment to (start, limit, step) constructor.
author Maged Rifaat <magedrifaat@gmail.com>
date Sat, 27 Aug 2022 13:41:44 +0200
parents 34617dd78f02
children 332a6ccac881
line wrap: on
line source

%!function load53027 (fname)
%!  global X
%!  X = 2;
%!  load (fname);
%!  assert (X, 1);
%!endfunction

%!function save53027 (fname)
%!  global X
%!  X = 1;
%!  save (fname, "X");
%!endfunction

%!test <*53027>
%! global X
%! X = 0;
%! fname = tempname ();
%! save53027 (fname);
%! assert (X, 1);
%! load53027 (fname);
%! assert (X, 1);
%! load53027 (fname);
%! assert (X, 1);
%! clear X
%! assert (exist ("X"), 0);
%! clear -global X;  # cleanup after test

%!test <*53027>
%! [a, b] = ntest53027a ();
%! assert ([a, b], [0, 0])
%! clear -global x;  # cleanup after test

%!test <*53027>
%! [a, b] = ntest53027b ();
%! assert ([a, b], [0, 0])
%! clear -global x;  # cleanup after test

%!test <*53027>
%! [a, b] = ntest53027c ();
%! assert ([a, b], [0, 0])
%! clear -global x;  # cleanup after test

## Previous bugs have caused segfaults when executing script twice.
%!test <*53027>
%! gtest53027
%! assert (isempty (a) && isempty (c))
%! assert (isglobal ("a") && isglobal ("c"))
%! assert (! exist ("b"))
%! assert (isempty (xx) && ! isglobal ("xx"))
%! gtest53027
%! assert (isempty (a) && isempty (c))
%! assert (isglobal ("a") && isglobal ("c"))
%! assert (! exist ("b"))
%! assert (isempty (xx) && ! isglobal ("xx"))
%! clear -global a b c;