Mercurial > hg > octave-lyh
annotate test/test_null_assign.m @ 8156:2bc8ec18b2ea
add more tests for null assignment
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 26 Sep 2008 17:35:49 -0400 |
parents | acfd80c08d60 |
children | 14dca190857f |
rev | line source |
---|---|
8119
acfd80c08d60
make null assignment more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2008 Jaroslav Hajek |
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 |
8156
2bc8ec18b2ea
add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8119
diff
changeset
|
36 % null strings should delete. [,] and [;] should delete. |
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 |
2bc8ec18b2ea
add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8119
diff
changeset
|
46 % null matrix stored anywhere should lose its special status |
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 |
2bc8ec18b2ea
add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8119
diff
changeset
|
54 % filtering a null matrix through a function should not delete |
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 |
2bc8ec18b2ea
add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8119
diff
changeset
|
58 % subsasgn should work the same way |
2bc8ec18b2ea
add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8119
diff
changeset
|
59 %!test |
2bc8ec18b2ea
add more tests for null assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8119
diff
changeset
|
60 %! a = ones (3); subsasgn (a, substruct ('()', {':',1:2}), []); assert (size (a), [3,1]) |
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 |