Mercurial > octave-nkf
comparison test/classes/test_classes.m @ 15985:f75ffcc82acb
Added tests for the legacy class system.
* double.m, eq.m, ge.m, gt.m, horzcat.m, ldivide.m, le.m, lt.m,
minus.m, mldivide.m, mpower.m, mrdivide.m, mtimes.m, ne.m, plus.m,
power.m, rdivide.m, times.m, uminus.m, uplus.m, vertcat.m: New
overloaded class methods.
* test_classes.m: Add tests. Rewrite some tests to ensure they run in
Matlab without modification.
author | Julien Bect <julien.bect@supelec.fr> |
---|---|
date | Sun, 27 Jan 2013 12:29:00 +0100 |
parents | 72c96de7a403 |
children | 980f79a7bb55 |
comparison
equal
deleted
inserted
replaced
15984:1eb3c67139f6 | 15985:f75ffcc82acb |
---|---|
1 ## Copyright (C) 2013 Julien Bect | |
1 ## Copyright (C) 2009-2012 Robert T. Short | 2 ## Copyright (C) 2009-2012 Robert T. Short |
2 ## | 3 ## |
3 ## This file is part of Octave. | 4 ## This file is part of Octave. |
4 ## | 5 ## |
5 ## Octave is free software; you can redistribute it and/or modify it | 6 ## Octave is free software; you can redistribute it and/or modify it |
20 %% Requires the path to contain the test classes. | 21 %% Requires the path to contain the test classes. |
21 %% | 22 %% |
22 %% Note: This script and all classes are also intended to run | 23 %% Note: This script and all classes are also intended to run |
23 %% in MATLAB to test compatibility. Don't break that! | 24 %% in MATLAB to test compatibility. Don't break that! |
24 %% | 25 %% |
26 %% Note(JBect, 2013/01/27) : in order to ease to process of testing | |
27 %% Matlab compatibility, the syntax assert(observed, expected) should | |
28 %% be avoided. I use assert(isequal(observed, expected) instead. | |
29 %% | |
25 %% To Do: This script tests to ensure that things done correctly work | 30 %% To Do: This script tests to ensure that things done correctly work |
26 %% corrrectly. It should also check that things done incorrectly | 31 %% corrrectly. It should also check that things done incorrectly |
27 %% error properly. | 32 %% error properly. |
28 %% | 33 %% |
29 %% The classes used for the tests reside in the test directory. | 34 %% The classes used for the tests reside in the test directory. |
35 %% Test the Snork class. The Snork class has a number of the standard | 40 %% Test the Snork class. The Snork class has a number of the standard |
36 %% methods that the others don't so we can test indexing and other | 41 %% methods that the others don't so we can test indexing and other |
37 %% features. | 42 %% features. |
38 %!shared snk, snk1, snk2 | 43 %!shared snk, snk1, snk2 |
39 %!test snk = Snork(); | 44 %!test snk = Snork(); |
40 %! assert(gick(snk),1) | 45 %! assert (isequal (gick (snk), 1)) |
41 %! assert(snk.gick,1) | 46 %! assert (isequal (snk.gick, 1)) |
42 %! assert(snk(2),1); | 47 %! assert (isequal (snk(2), 1)); |
43 %! assert(snk{end},3); | 48 %! assert (isequal (snk{end}, 3)); |
44 %!test snk = gick(snk,2); | 49 %!test snk = gick (snk, 2); |
45 %! assert(gick(snk),2) | 50 %! assert (isequal (gick (snk), 2)) |
46 %!test snk = set(snk,'gick',7); | 51 %!test snk = set (snk, 'gick', 7); |
47 %! assert(get(snk, 'gick'), 7) | 52 %! assert (isequal (get (snk, 'gick'), 7)) |
48 %!test snk.gick = 4; | 53 %!test snk.gick = 4; |
49 %! assert(gick(snk),4) | 54 %! assert (isequal (gick (snk),4)) |
50 %! snk(1) = 3; | 55 %! snk(1) = 3; |
51 %!test snk{end} = 9; | 56 %!test snk{end} = 9; |
52 %! assert(cack(snk),[3 1 2 9]) | 57 %! assert (isequal (cack (snk), [3 1 2 9])) |
53 %! assert(getStash(snk),1) % Check private functions. | 58 %! assert (isequal (getStash (snk), 1)) % Check private functions. |
54 %! assert(isobject(snk)) | 59 %! assert (isobject (snk)) |
55 %! assert(class(snk),'Snork') | 60 %! assert (isequal (class (snk), 'Snork')) |
56 %! assert(isa(snk,'Snork')) | 61 %! assert (isa (snk, 'Snork')) |
57 %! assert(~isa(snk,'Sneetch')) | 62 %! assert (~isa (snk, 'Sneetch')) |
58 %! assert(ismethod(snk,'gick')) | 63 %! assert (ismethod (snk, 'gick')) |
59 %! assert(~ismethod(snk,'bletch')) | 64 %! assert (~ismethod (snk, 'bletch')) |
60 %! assert(exist('snk')) | 65 %! assert (exist ('snk') == 1) |
61 %! assert(~exist('blink')) | 66 %! assert (exist ('blink') == 0) |
62 %!test snk1 = Snork(snk); | 67 %!test snk1 = Snork(snk); |
63 %! assert(class(snk1),'Snork') | 68 %! assert (isequal (class (snk1), 'Snork')) |
64 %! assert(gick(snk1),4) | 69 %! assert (isequal (gick (snk1), 4)) |
65 %!test snk2 = Snork(-3); | 70 %!test snk2 = Snork(-3); |
66 %! assert(class(snk2),'Snork') | 71 %! assert (isequal (class (snk2), 'Snork')) |
67 %! assert(gick(snk2),-3) | 72 %! assert (isequal (gick (snk2), -3)) |
68 %!test x=[1 2 3 4]; | 73 %!test x = [1 2 3 4]; |
69 %! assert(x(snk),1); | 74 %! assert (isequal (x(snk), 1)) |
70 %% x=methods('Snork'); % Need to test the methods function. | 75 %% x = methods('Snork'); % Need to test the methods function. |
71 %% save temp snk; | 76 %% save temp snk; |
72 %% load temp % This load causes a segment fault. | 77 %% load temp % This load causes a segment fault. |
73 %% assert(cack(snk),[-1 -2 -3 -4]); % This is a major bug! | 78 %% assert (isequal(cack(snk), [-1 -2 -3 -4])); % This is a major bug! |
74 | 79 |
75 %% The Spork class is a near clone of Snork but without as many standard | 80 %% The Spork class is a near clone of Snork but without as many standard |
76 %% methods. We are testing no new octave features, but this is makes | 81 %% methods. We are testing no new octave features, but this is makes |
77 %% sure that we haven't bollixed up the Spork class if we should make | 82 %% sure that we haven't bollixed up the Spork class if we should make |
78 %% changes. We use Spork in the class hierarchy. | 83 %% changes. We use Spork in the class hierarchy. |
79 %!shared sprk | 84 %!shared sprk |
80 %!test sprk = Spork(); | 85 %!test sprk = Spork(); |
81 %! assert(geek(sprk),1) | 86 %! assert (isequal (geek (sprk), 1)) |
82 %!test sprk = geek(sprk,3); | 87 %!test sprk = geek (sprk, 3); |
83 %! assert(geek(sprk),3) | 88 %! assert (isequal (geek (sprk), 3)) |
84 %!test sprk = set(sprk,'geek',7); | 89 %!test sprk = set (sprk,'geek',7); |
85 %! assert(get(sprk, 'geek'), 7) | 90 %! assert (isequal (get (sprk, 'geek'), 7)) |
86 %! assert(class(sprk),'Spork'); | 91 %! assert (isequal (class (sprk), 'Spork')) |
87 %! assert(isa(sprk,'Spork')) | 92 %! assert (isa (sprk, 'Spork')) |
88 | 93 |
89 %% The Blork class is a near clone of Snork but without as many standard | 94 %% The Blork class is a near clone of Snork but without as many standard |
90 %% methods. We are testing no new octave features, but this is makes | 95 %% methods. We are testing no new octave features, but this is makes |
91 %% sure that we haven't bollixed up the Blork class if we should make | 96 %% sure that we haven't bollixed up the Blork class if we should make |
92 %% changes. We use Blork in the class hierarchy. | 97 %% changes. We use Blork in the class hierarchy. |
93 %!shared blrk | 98 %!shared blrk |
94 %!test blrk = Blork(); | 99 %!test blrk = Blork(); |
95 %! assert(bleek(blrk),1) | 100 %! assert (isequal (bleek(blrk), 1)) |
96 %!test blrk = bleek(blrk,3); | 101 %!test blrk = bleek (blrk, 3); |
97 %! assert(bleek(blrk),3) | 102 %! assert (isequal (bleek (blrk), 3)) |
98 %!test blrk = set(blrk,'bleek',13); | 103 %!test blrk = set (blrk, 'bleek', 13); |
99 %! assert(get(blrk, 'bleek'), 13) | 104 %! assert (isequal (get (blrk, 'bleek'), 13)) |
100 %! assert(class(blrk),'Blork'); | 105 %! assert (isequal (class (blrk), 'Blork')) |
101 %! assert(isa(blrk,'Blork')) | 106 %! assert (isa (blrk,'Blork')) |
102 | 107 |
103 %% The Cork class is a near clone of Snork but without as many standard | 108 %% The Cork class is a near clone of Snork but without as many standard |
104 %% methods. We are testing no new octave features, but this is makes | 109 %% methods. We are testing no new octave features, but this is makes |
105 %% sure that we haven't bollixed up the Cork class if we should make | 110 %% sure that we haven't bollixed up the Cork class if we should make |
106 %% changes. We use Cork in the class hierarchy. | 111 %% changes. We use Cork in the class hierarchy. |
107 %!shared crk | 112 %!shared crk |
108 %!test crk = Cork(23); | 113 %!test crk = Cork(23); |
109 %! assert(click(crk),23) | 114 %! assert (isequal (click(crk), 23)) |
110 %!test crk = click(crk,3); | 115 %!test crk = click(crk,3); |
111 %! assert(click(crk),3) | 116 %! assert (isequal (click(crk), 3)) |
112 %!test crk = set(crk,'click',13); | 117 %!test crk = set (crk, 'click', 13); |
113 %! assert(get(crk, 'click'), 13) | 118 %! assert (isequal (get (crk, 'click'), 13)) |
114 %! assert(class(crk),'Cork'); | 119 %! assert (isequal (class (crk),'Cork')) |
115 %! assert(isa(crk,'Cork')) | 120 %! assert (isa (crk, 'Cork')) |
116 | 121 |
117 %% The Dork class tests single inheritance. | 122 %% The Dork class tests single inheritance. |
118 %!shared drk | 123 %!shared drk |
119 %!test drk = Dork(); | 124 %!test drk = Dork(); |
120 %! assert(gack(drk),0) | 125 %! assert (isequal (gack (drk),0)) |
121 %!test drk = gack(drk,-2); | 126 %!test drk = gack (drk,-2); |
122 %! assert(gack(drk),-2) | 127 %! assert (isequal (gack (drk),-2)) |
123 %!test drk = gick(drk,2); | 128 %!test drk = gick (drk,2); |
124 %! assert(gick(drk),2); | 129 %! assert (isequal (gick (drk),2)) |
125 %!test drk = set(drk, 'gick',3, 'gack',-3); | 130 %!test drk = set (drk, 'gick',3, 'gack',-3); |
126 %! assert(get(drk, 'gick'), 3) | 131 %! assert (isequal (get (drk, 'gick'), 3)) |
127 %! assert(get(drk, 'gack'), -3) | 132 %! assert (isequal (get (drk, 'gack'), -3)) |
128 %! assert(class(drk),'Dork') | 133 %! assert (isequal (class (drk),'Dork')) |
129 %! assert(isa(drk,'Dork')) | 134 %! assert (isa (drk, 'Dork')) |
130 %! assert(isa(drk,'Snork')) | 135 %! assert (isa (drk, 'Snork')) |
131 %! assert(getStash(drk),2) | 136 %! assert (isequal (getStash (drk), 2)) |
132 %!test drk1 = Dork(drk); | 137 %!test drk1 = Dork(drk); |
133 %! assert(class(drk1),'Dork') | 138 %! assert (isequal (class (drk1), 'Dork')) |
134 %! assert(isa(drk1,'Snork')) | 139 %! assert (isa (drk1, 'Snork')) |
135 %! assert(gick(drk1),3) | 140 %! assert (isequal (gick (drk1), 3)) |
136 %! assert(gack(drk1),-3) | 141 %! assert (isequal (gack (drk1), -3)) |
137 %!test drk2 = Dork(-4,4); | 142 %!test drk2 = Dork(-4, 4); |
138 %! assert(class(drk2),'Dork') | 143 %! assert (isequal (class (drk2), 'Dork')) |
139 %! assert(isa(drk2,'Snork')) | 144 %! assert (isa (drk2, 'Snork')) |
140 %! assert(gick(drk2),-4) | 145 %! assert (isequal (gick (drk2), -4)) |
141 %! assert(gack(drk2),4) | 146 %! assert (isequal (gack (drk2), 4)) |
142 | 147 |
143 %% The Pork class is essentially a clone of Dork. It is used as part | 148 %% The Pork class is essentially a clone of Dork. It is used as part |
144 %% of the multiple inheritance test. | 149 %% of the multiple inheritance test. |
145 %!shared prk, drk | 150 %!shared prk, drk |
146 %!test prk = Pork(); | 151 %!test prk = Pork(); |
147 %! assert(geek(prk),1) | 152 %! assert (isequal (geek (prk), 1)) |
148 %! assert(gurk(prk),0) | 153 %! assert (isequal (gurk (prk), 0)) |
149 %!test prk = gurk(prk,-3); | 154 %!test prk = gurk (prk,-3); |
150 %! assert(gurk(prk),-3) | 155 %! assert (isequal (gurk (prk), -3)) |
151 %!test prk = geek(prk,9); | 156 %!test prk = geek (prk,9); |
152 %! assert(geek(prk),9) | 157 %! assert (isequal (geek (prk), 9)) |
153 %! assert(class(prk),'Pork') | 158 %! assert (isequal (class (prk), 'Pork')) |
154 %! assert(isa(prk,'Pork')) | 159 %! assert (isa (prk, 'Pork')) |
155 %! assert(isa(prk,'Spork')) | 160 %! assert (isa (prk, 'Spork')) |
156 %!test drk = Dork(); % Precedence. | 161 %!test drk = Dork(); % Precedence. |
157 %! assert(bling(drk,prk),2) | 162 %! assert (isequal (bling (drk, prk), 2)) |
158 %! assert(bling(prk,drk),2) | 163 %! assert (isequal (bling (prk, drk), 2)) |
159 | 164 |
160 %% The Gork class tests aggregation and multiple inheritance. | 165 %% The Gork class tests aggregation and multiple inheritance. |
161 %!shared grk | 166 %!shared grk |
162 %!test grk = Gork(); | 167 %!test grk = Gork(); |
163 %! assert(gick(grk),1) | 168 %! assert (isequal (gick (grk), 1)) |
164 %! assert(geek(grk),1) | 169 %! assert (isequal (geek (grk), 1)) |
165 %! assert(gack(grk),0) | 170 %! assert (isequal (gack (grk), 0)) |
166 %! assert(gurk(grk),0) | 171 %! assert (isequal (gurk (grk), 0)) |
167 %! assert(bleek(grk),1) | 172 %! assert (isequal (bleek (grk), 1)) |
168 %! assert(gark(grk),-2) | 173 %! assert (isequal (gark(grk), -2)) |
169 %! assert(click(cork(grk)),17) | 174 %! assert (isequal (click (cork (grk)), 17)) |
170 %! assert(class(cork(grk)),'Cork') | 175 %! assert (isequal (class (cork (grk)), 'Cork')) |
171 %!test grk = gick(grk,3); | 176 %!test grk = gick (grk, 3); |
172 %!test grk = geek(grk,4); | 177 %!test grk = geek (grk, 4); |
173 %!test grk = gack(grk,-9); | 178 %!test grk = gack (grk, -9); |
174 %!test grk = gurk(grk,-8); | 179 %!test grk = gurk (grk, -8); |
175 %!test grk = bleek(grk,-7); | 180 %!test grk = bleek (grk, -7); |
176 %!test grk = gark(grk,-6); | 181 %!test grk = gark (grk, -6); |
177 %!test grk = cork(grk,click(cork(grk),23)); | 182 %!test grk = cork (grk, click (cork (grk), 23)); |
178 %! assert(gick(grk),3) | 183 %! assert (isequal (gick (grk), 3)) |
179 %! assert(geek(grk),4) | 184 %! assert (isequal (geek (grk), 4)) |
180 %! assert(gack(grk),-9) | 185 %! assert (isequal (gack (grk), -9)) |
181 %! assert(gurk(grk),-8) | 186 %! assert (isequal (gurk (grk), -8)) |
182 %! assert(bleek(grk),-7) | 187 %! assert (isequal (bleek (grk), -7)) |
183 %! assert(gark(grk),-6) | 188 %! assert (isequal (gark (grk), -6)) |
184 %! assert(click(cork(grk)),23) | 189 %! assert (isequal (click (cork (grk)), 23)) |
185 %!test | 190 %!test |
186 %! cork1 = Cork(13); | 191 %! cork1 = Cork(13); |
187 %! grk = set(grk, 'gick',-5, 'gack',-6, 'gark',-7, 'cork',cork1); | 192 %! grk = set (grk, 'gick', -5, 'gack', -6, 'gark', -7, 'cork', cork1); |
188 %! assert(get(grk,'gick'),-5) | 193 %! assert (isequal (get (grk, 'gick'), -5)) |
189 %! assert(get(grk,'gack'),-6) | 194 %! assert (isequal (get (grk, 'gack'), -6)) |
190 %! assert(get(grk,'gark'),-7) | 195 %! assert (isequal (get (grk, 'gark'), -7)) |
191 %! assert(click(get(grk, 'cork')),13); | 196 %! assert (isequal (click(get (grk, 'cork')), 13)) |
192 %!test grk = set(grk, 'cork',12); | 197 %!test grk = set (grk, 'cork', 12); |
193 %! assert(click(get(grk, 'cork')),12); | 198 %! assert (isequal (click(get (grk, 'cork')),12)); |
194 %! assert(class(cork(grk)),'Cork') | 199 %! assert (isequal (class (cork(grk)), 'Cork')) |
195 %! assert(class(grk),'Gork') | 200 %! assert (isequal (class (grk), 'Gork')) |
196 %! assert(isa(grk,'Gork')) | 201 %! assert (isa (grk, 'Gork')) |
197 %! assert(isa(grk,'Dork')) | 202 %! assert (isa (grk, 'Dork')) |
198 %! assert(isa(grk,'Pork')) | 203 %! assert (isa (grk, 'Pork')) |
199 %! assert(isa(grk,'Blork')) | 204 %! assert (isa (grk, 'Blork')) |
200 %! assert(isa(grk,'Snork')) | 205 %! assert (isa (grk, 'Snork')) |
201 %! assert(isa(grk,'Spork')) | 206 %! assert (isa (grk, 'Spork')) |
207 | |
208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
209 %% Testing (some) overloaded operators %% | |
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
211 | |
212 %% Common variables for testing overloaded operators | |
213 %!shared x1, x2, x3, s1, s2, s3 | |
214 %! x1 = 1 + rand(3); s1 = Snork(x1); | |
215 %! x2 = 1 + rand(3); s2 = Snork(x2); | |
216 %! x3 = diag([1 2 3]); s3 = Snork(x3); | |
217 | |
218 %% Test overloaded plus (+) and uplus (unitary +) for the Snork class | |
219 %!test s = s1 + s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 + x2)); | |
220 %!test s = s1 + x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 + x2)); | |
221 %!test s = x1 + s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 + x2)); | |
222 %!test s = +s1; assert (isequal (s, s1)); | |
223 | |
224 %% Test overloaded minus (-) for the Snork class | |
225 %!test s = s1 - s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 - x2)); | |
226 %!test s = s1 - x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 - x2)); | |
227 %!test s = x1 - s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 - x2)); | |
228 %!test s = -s1; assert (isequal (s, Snork(-x1))); | |
229 | |
230 %% Test overloaded mtimes (*) for the Snork class | |
231 %!test s = s1 * s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 * x2)); | |
232 %!test s = s1 * x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 * x2)); | |
233 %!test s = x1 * s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 * x2)); | |
234 | |
235 %% Test overloaded times (.*) for the Snork class | |
236 %!test s = s1 .* s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .* x2)); | |
237 %!test s = s1 .* x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .* x2)); | |
238 %!test s = x1 .* s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .* x2)); | |
239 | |
240 %% Test overloaded mpower (^) for the Snork class | |
241 %!test s = s1 ^ 3; assert (isa (s, 'Snork') && isequal (s.gick, x1 ^ 3)); | |
242 %!error <mpower Snork!!!> s = s1 ^ s1; | |
243 %!error <mpower Snork!!!> s = 20 ^ s1; | |
244 | |
245 %% Test overloaded power (.^) for the Snork class | |
246 %!test s = s1 .^ 2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .^ 2)); | |
247 %!error <power Snork!!!> s = s1 .^ s1; | |
248 %!error <power Snork!!!> s = 20 .^ s1; | |
249 | |
250 %% Test overloaded rdivide (./) for the Snork class | |
251 %!test s = s1 ./ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 ./ x2)); | |
252 %!test s = s1 ./ x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 ./ x2)); | |
253 %!test s = x1 ./ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 ./ x2)); | |
254 | |
255 %% Test overloaded ldivide (.\) for the Snork class | |
256 %!test s = s1 .\ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .\ x2)); | |
257 %!test s = s1 .\ x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .\ x2)); | |
258 %!test s = x1 .\ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .\ x2)); | |
259 | |
260 %% Test overloaded mrdivide (/) for the Snork class | |
261 %!test s = s1 / s3; assert (isa (s, 'Snork') && isequal (s.gick, x1 / x3)); | |
262 %!test s = s1 / x3; assert (isa (s, 'Snork') && isequal (s.gick, x1 / x3)); | |
263 %!test s = x1 / s3; assert (isa (s, 'Snork') && isequal (s.gick, x1 / x3)); | |
264 | |
265 %% Test overloaded mldivide (\) for the Snork class | |
266 %!test s = s3 \ s2; assert (isa (s, 'Snork') && isequal (s.gick, x3 \ x2)); | |
267 %!test s = s3 \ x2; assert (isa (s, 'Snork') && isequal (s.gick, x3 \ x2)); | |
268 %!test s = x3 \ s2; assert (isa (s, 'Snork') && isequal (s.gick, x3 \ x2)); | |
269 | |
270 %% Test overloaded eq (==) for the Snork class | |
271 %!assert (s1 == s1); | |
272 %!assert (s1 == x1); | |
273 %!assert (x1 == s1); | |
274 %!assert (~(s1 == (s1 + 1))); | |
275 %!assert (~(s1 == (x1 + 1))); | |
276 %!assert (~(x1 == (s1 + 1))); | |
277 | |
278 %% Test overloaded ne (~=) for the Snork class | |
279 %!assert (~(s1 ~= s1)); | |
280 %!assert (~(s1 ~= x1)); | |
281 %!assert (~(x1 ~= s1)); | |
282 %!assert (s1 ~= (s1 + 1)) | |
283 %!assert (x1 ~= (s1 + 1)) | |
284 %!assert (s1 ~= (x1 + 1)) | |
285 | |
286 %% Test overloaded lt (<) for the Snork class | |
287 %!assert (s1 < (s1 + 1)) | |
288 %!assert (s1 < (x1 + 1)) | |
289 %!assert (x1 < (s1 + 1)) | |
290 | |
291 %% Test overloaded gt (>) for the Snork class | |
292 %!assert (s1 > (s1 - 1)) | |
293 %!assert (s1 > (x1 - 1)) | |
294 %!assert (x1 > (s1 - 1)) | |
295 | |
296 %% Test overloaded lt (<=) for the Snork class | |
297 %!assert (s1 <= (s1 + 1)) | |
298 %!assert (s1 <= (x1 + 1)) | |
299 %!assert (x1 <= (s1 + 1)) | |
300 | |
301 %% Test overloaded gt (>=) for the Snork class | |
302 %!assert (s1 >= (s1 - 1)) | |
303 %!assert (s1 >= (x1 - 1)) | |
304 %!assert (x1 >= (s1 - 1)) | |
305 | |
306 %% Test overloaded vertcat() for the Snork class | |
307 %% See bug #38170 (http://savannah.gnu.org/bugs/?38170) | |
308 %!test s = [s1; s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); | |
309 %!xtest s = [s1; x2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); | |
310 %!xtest s = [x1; s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); | |
311 | |
312 %% Test overloaded horzcat() for the Snork class | |
313 %% See bug #38170 (http://savannah.gnu.org/bugs/?38170) | |
314 %!test s = [s1 s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); | |
315 %!xtest s = [s1 x2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); | |
316 %!xtest s = [x1 s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); | |
317 |