annotate test/test_null_assign.m @ 14200:64d9f33313cc stable rc-3-6-0-1

3.6.0-rc1 release candidate * configure.ac (AC_INIT): Version is now 3.6.0-rc1. (OCTAVE_RELEASE_DATE): Now 2012-01-12.
author John W. Eaton <jwe@octave.org>
date Thu, 12 Jan 2012 14:31:50 -0500
parents 72c96de7a403
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14131
diff changeset
1 ## Copyright (C) 2008-2012 Jaroslav Hajek
8119
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2 ##
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
3 ## This file is part of Octave.
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4 ##
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 ## your option) any later version.
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 ##
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 ## General Public License for more details.
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 ##
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 %! a = 1:3; a(:) = []; assert (size (a), [0, 0])
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22 %! a = 1:3; a(1:3) = []; assert (size (a), [1, 0])
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
23 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
24 %! a = (1:3).'; a(1:3) = []; assert (size (a), [0, 1])
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26 %! a = ones (3); a(:,:) = []; assert (size (a), [0, 3])
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28 %! a = ones (3); a(1:3,:) = []; assert (size (a), [0, 3])
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30 %! a = ones (3); a(:,1:3) = []; assert (size (a), [3, 0])
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 %! a = ones (3); fail ("a(1:2,1:2) = []", ".*");
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 %!test
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 %! a = ones (3); fail ("a(1:3,1:3) = []", ".*");
acfd80c08d60 make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
36 ## null strings should delete. [,] and [;] should delete.
8156
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
37 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
38 %! a = ones (3); a(1:2,:) = [,]; assert (size (a), [1,3])
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
39 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
40 %! a = ones (3); a(1:2,:) = [;]; assert (size (a), [1,3])
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
41 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
42 %! a = ones (3); a(1:2,:) = ''; assert (size (a), [1,3])
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
43 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
44 %! a = ones (3); a(1:2,:) = ""; assert (size (a), [1,3])
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
45
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
46 ## null matrix stored anywhere should lose its special status
8156
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
47 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
48 %! a = ones (3); b = []; fail ("a(:,1:3) = b", ".")
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
49 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
50 %! a = ones (3); b{1} = []; fail ("a(:,1:3) = b{1}", ".")
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
51 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
52 %! a = ones (3); b.x = []; fail ("a(:,1:3) = b.x", ".")
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
53
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
54 ## filtering a null matrix through a function should not delete
8156
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
55 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
56 %! a = ones (3); fail ("a(:,1:3) = double ([])")
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
57
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
58 ## subsasgn should work the same way
8156
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
59 %!test
9369
14dca190857f fix null assign test
Jaroslav Hajek <highegg@gmail.com>
parents: 8156
diff changeset
60 %! a = ones (3); a = subsasgn (a, substruct ('()', {':',1:2}), []); assert (size (a), [3,1])
8156
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
61 %!test
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
62 %! a = ones (3); b = []; fail ("subsasgn (a, substruct ('()', {':',1:2}), b)", ".")
2bc8ec18b2ea add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8119
diff changeset
63