Mercurial > hg > octave-nkf
annotate test/null-assign.tst @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18212
diff
changeset
|
1 ## Copyright (C) 2008-2015 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 |
18212
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
64 %!test |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
65 %! classes = {@int8, @int16, @int32, @int64, ... |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
66 %! @uint8, @uint16, @uint32, @uint64, ... |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
67 %! @single, @double, @logical}; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
68 %! for i = 1:numel (classes) |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
69 %! cls = classes{i}; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
70 %! x = cls ([1, 2, 3]); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
71 %! cls_nm = class (x); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
72 %! x(2) = []; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
73 %! assert (x, cls ([1, 3])); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
74 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
75 %! x(2) = []; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
76 %! assert (x, cls (1)); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
77 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
78 %! x(1) = []; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
79 %! assert (x, cls (zeros (1, 0))); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
80 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
81 %! endfor |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
82 %! for i = 1:numel (classes) |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
83 %! cls = classes{i}; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
84 %! x = cls ([1, 2, 3]); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
85 %! cls_nm = class (x); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
86 %! x(2) = ''; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
87 %! assert (x, cls ([1, 3])); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
88 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
89 %! x(2) = ''; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
90 %! assert (x, cls (1)); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
91 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
92 %! x(1) = ''; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
93 %! assert (x, cls (zeros (1, 0))); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
94 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
95 %! endfor |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
96 %! for i = 1:numel (classes) |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
97 %! cls = classes{i}; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
98 %! x = cls ([1, 2, 3]); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
99 %! cls_nm = class (x); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
100 %! x(2) = ""; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
101 %! assert (x, cls ([1, 3])); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
102 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
103 %! x(2) = ""; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
104 %! assert (x, cls (1)); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
105 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
106 %! x(1) = ""; |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
107 %! assert (x, cls (zeros (1, 0))); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
108 %! assert (class (x), cls_nm); |
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
109 %! endfor |