# HG changeset patch # User Jaroslav Hajek # Date 1222464949 14400 # Node ID 2bc8ec18b2ea010fed1ef69bcb24ec2e816e3410 # Parent 344c9b6532a2dbc0f5ca9a8abff57530f4225274 add more tests for null assignment diff --git a/test/ChangeLog b/test/ChangeLog --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2008-09-26 Jaroslav Hajek + + * test_null_assign.m: More test for null assignments. + 2008-09-18 Jaroslav Hajek * test_null_assign.m: New tests. diff --git a/test/test_null_assign.m b/test/test_null_assign.m --- a/test/test_null_assign.m +++ b/test/test_null_assign.m @@ -33,3 +33,31 @@ %!test %! a = ones (3); fail ("a(1:3,1:3) = []", ".*"); +% null strings should delete. [,] and [;] should delete. +%!test +%! a = ones (3); a(1:2,:) = [,]; assert (size (a), [1,3]) +%!test +%! a = ones (3); a(1:2,:) = [;]; assert (size (a), [1,3]) +%!test +%! a = ones (3); a(1:2,:) = ''; assert (size (a), [1,3]) +%!test +%! a = ones (3); a(1:2,:) = ""; assert (size (a), [1,3]) + +% null matrix stored anywhere should lose its special status +%!test +%! a = ones (3); b = []; fail ("a(:,1:3) = b", ".") +%!test +%! a = ones (3); b{1} = []; fail ("a(:,1:3) = b{1}", ".") +%!test +%! a = ones (3); b.x = []; fail ("a(:,1:3) = b.x", ".") + +% filtering a null matrix through a function should not delete +%!test +%! a = ones (3); fail ("a(:,1:3) = double ([])") + +% subsasgn should work the same way +%!test +%! a = ones (3); subsasgn (a, substruct ('()', {':',1:2}), []); assert (size (a), [3,1]) +%!test +%! a = ones (3); b = []; fail ("subsasgn (a, substruct ('()', {':',1:2}), b)", ".") +