Mercurial > hg > octave-lyh
annotate test/null-assign.tst @ 17503:cff399332a7f
meshgrid.m: Overhaul function.
* scripts/plot/meshgrid.m: Redo docstring and add example and comparison to
ndgrid. Put input validation first. Add %!error blocks for input validation.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 25 Sep 2013 12:37:53 -0700 |
parents | 1af8d21608b7 |
children |
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 | 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 |