diff test/struct.tst @ 23880:1b232c0c19e6

Empty indexing of a struct should return the entire struct (bug #51633). * ov-struct.cc (do_index_op): Check size of idx list. If it is zero, return the struct itself, otherwise continue and perform indexing operation. * test/struct.tst: Add test for proper behavior.
author Rik <rik@octave.org>
date Fri, 11 Aug 2017 08:05:01 -0700
parents 092078913d54
children 194eb4bd202b
line wrap: on
line diff
--- a/test/struct.tst	Thu Aug 10 21:17:09 2017 -0700
+++ b/test/struct.tst	Fri Aug 11 08:05:01 2017 -0700
@@ -230,9 +230,19 @@
 %! s(3).foo = 42;
 %! assert (s(3), struct ("foo", 42));
 
+## empty index should return entire struct
+%!test <51633>
+%! x.a = 1:10;
+%! y = x;
+%! assert (! isempty (y));
+%! assert (y, x);
+%! z = x();
+%! assert (! isempty (z));
+%! assert (z, x);
+%! assert (z, y);
+
 ## test assigning to multi-dim struct with trailing singleton dimensions,
-## Bug #35841.
-%!test
+%!test <35841>
 %! a(1,1,1).b(1) = 1;
 %! a(1,1,1).b(1) = 2;
 %! a(1,1,:).b(1) = 3;