Mercurial > hg > octave-lyh
changeset 8156:2bc8ec18b2ea
add more tests for null assignment
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 26 Sep 2008 17:35:49 -0400 |
parents | 344c9b6532a2 |
children | c0b8546c0020 |
files | test/ChangeLog test/test_null_assign.m |
diffstat | 2 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2008-09-26 Jaroslav Hajek <highegg@gmail.com> + + * test_null_assign.m: More test for null assignments. + 2008-09-18 Jaroslav Hajek <highegg@gmail.com> * test_null_assign.m: New tests.
--- 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)", ".") +