|
24 | 24 | ########################################################################
|
25 | 25 |
|
26 | 26 | ## No constructor, ConstructOnLoad = false, no loadobj/saveobj
|
27 |
| -%!test |
| 27 | +%!testif HAVE_ZLIB |
28 | 28 | %! obj = regular_class ();
|
29 | 29 | %! obj.a = 1;
|
30 | 30 | %! obj.b = "Regular Class";
|
|
47 | 47 |
|
48 | 48 | ## Constructor defined, ConstructOnLoad = false, no loadobj/saveobj
|
49 | 49 | ## (ensures that constructor is NOT called on load)
|
50 |
| -%!test |
| 50 | +%!testif HAVE_ZLIB |
51 | 51 | %! obj = regular_class_with_constructor ();
|
52 | 52 | %! obj.a = [];
|
53 | 53 | %! savefile = tempname ();
|
|
61 | 61 | %! end_unwind_protect
|
62 | 62 |
|
63 | 63 | ## No constructor, ConstructOnLoad = false, no loadobj/saveobj, nested object
|
64 |
| -%!test |
| 64 | +%!testif HAVE_ZLIB |
65 | 65 | %! obj = regular_class ();
|
66 | 66 | %! obj.a = regular_class_with_constructor ();
|
67 | 67 | %! savefile = tempname ();
|
|
76 | 76 | %! end_unwind_protect
|
77 | 77 |
|
78 | 78 | ## No constructor, ConstructOnLoad = false, no loadobj/saveobj, nested object inside a struct
|
79 |
| -%!test <45833> |
| 79 | +%!testif HAVE_ZLIB <45833> |
80 | 80 | %! obj = regular_class ();
|
81 | 81 | %! s.obj_field = regular_class_with_constructor ();
|
82 | 82 | %! obj.a = s;
|
|
91 | 91 | %! end_unwind_protect
|
92 | 92 |
|
93 | 93 | ## Vector of value class objects.
|
94 |
| -%!test |
| 94 | +%!testif HAVE_ZLIB |
95 | 95 | %! obj = regular_class;
|
96 | 96 | %! obj.a = 1;
|
97 | 97 | %! obj(2) = regular_class;
|
|
108 | 108 | %! end_unwind_protect
|
109 | 109 |
|
110 | 110 | ## Matrix of value class objects.
|
111 |
| -%!test <*65179> |
| 111 | +%!testif HAVE_ZLIB <*65179> |
112 | 112 | %! obj = regular_class;
|
113 | 113 | %! obj.a = 1;
|
114 | 114 | %! obj(2,3) = regular_class;
|
|
126 | 126 | %! end_unwind_protect
|
127 | 127 |
|
128 | 128 | ## No constructor, ConstructOnLoad = false, saveobj returns an object, no loadobj
|
129 |
| -%!test |
| 129 | +%!testif HAVE_ZLIB |
130 | 130 | %! obj = saveobj_obj_class ();
|
131 | 131 | %! obj.a = 1;
|
132 | 132 | %! obj.b = 3;
|
|
143 | 143 | %! end_unwind_protect
|
144 | 144 |
|
145 | 145 | ## No constructor, ConstructOnLoad = false, saveobj returns a struct, no loadobj
|
146 |
| -%!test |
| 146 | +%!testif HAVE_ZLIB |
147 | 147 | %! obj = saveobj_struct_class ();
|
148 | 148 | %! obj.a = 1;
|
149 | 149 | %! savefile = tempname ();
|
|
158 | 158 | %! end_unwind_protect
|
159 | 159 |
|
160 | 160 | ## No constructor, ConstructOnLoad = false, loadobj is defined, no saveobj
|
161 |
| -%!test |
| 161 | +%!testif HAVE_ZLIB |
162 | 162 | %! obj = loadobj_class ();
|
163 | 163 | %! obj.a = 1;
|
164 | 164 | %! savefile = tempname ();
|
|
173 | 173 |
|
174 | 174 | ## No constructor, ConstructOnLoad = false, loadobj is defined, no saveobj
|
175 | 175 | ## Class definition changes between saving and loading the object
|
176 |
| -%!test <67414> |
| 176 | +%!testif HAVE_ZLIB <67414> |
177 | 177 | %! clear classes;
|
178 | 178 | %! obj = loadobj_changed_class ();
|
179 | 179 | %! obj.a = 0;
|
|
199 | 199 | %! end_unwind_protect
|
200 | 200 |
|
201 | 201 | ## No constructor, ConstructOnLoad = false, loadobj is defined, saveobj is defined
|
202 |
| -%!test |
| 202 | +%!testif HAVE_ZLIB |
203 | 203 | %! obj = loadobj_saveobj_class ();
|
204 | 204 | %! obj.a = 1;
|
205 | 205 | %! savefile = tempname ();
|
|
213 | 213 | %! end_unwind_protect
|
214 | 214 |
|
215 | 215 | ## Constructor defined, ConstructOnLoad = false, custom return type for loadobj/saveobj
|
216 |
| -%!test |
| 216 | +%!testif HAVE_ZLIB |
217 | 217 | %! obj = custom_saveobj ();
|
218 | 218 | %! savefile = tempname ();
|
219 | 219 | %! save ('-v7', savefile, 'obj');
|
|
226 | 226 | %! end_unwind_protect
|
227 | 227 |
|
228 | 228 | ## No constructor, ConstructOnLoad = false, undefined return variable from saveobj (should return default initialized classdef)
|
229 |
| -%!test |
| 229 | +%!testif HAVE_ZLIB |
230 | 230 | %! obj = invalid_saveobj_class ();
|
231 | 231 | %! obj.a = 1;
|
232 | 232 | %! savefile = tempname ();
|
|
240 | 240 | %! end_unwind_protect
|
241 | 241 |
|
242 | 242 | ## No constructor, ConstructOnLoad = false, undefined return variable from saveobj (should emit a warning)
|
243 |
| -%!warning <saveobj.*does not return.*value> |
| 243 | +%!testif HAVE_ZLIB |
244 | 244 | %! obj = invalid_saveobj_class ();
|
245 | 245 | %! obj.a = 1;
|
246 | 246 | %! savefile = tempname ();
|
247 |
| -%! save ('-v7', savefile, 'obj'); |
248 |
| -%! delete (savefile); |
| 247 | +%! lastwarn (""); |
| 248 | +%! unwind_protect |
| 249 | +%! save ('-v7', savefile, 'obj'); |
| 250 | +%! assert (! isempty (regexp (lastwarn (), "saveobj.*does not return.*value", "once"))); |
| 251 | +%! unwind_protect_cleanup |
| 252 | +%! delete (savefile); |
| 253 | +%! end_unwind_protect |
249 | 254 |
|
250 | 255 | ## Handle class, no constructor, ConstructOnLoad = false, no loadobj/saveobj
|
251 |
| -%!test |
| 256 | +%!testif HAVE_ZLIB |
252 | 257 | %! obj1 = regular_handle_class ();
|
253 | 258 | %! obj2 = obj1;
|
254 | 259 | %! obj2.a = 1;
|
|
264 | 269 | %! end_unwind_protect
|
265 | 270 |
|
266 | 271 | ## Handle class, no constructor, ConstructOnLoad = false, no loadobj/saveobj, circular references
|
267 |
| -%!test |
| 272 | +%!testif HAVE_ZLIB |
268 | 273 | %! obj = regular_handle_class ();
|
269 | 274 | %! obj.a = regular_handle_class ();
|
270 | 275 | %! obj.c = 1;
|
|
286 | 291 | %! end_unwind_protect
|
287 | 292 |
|
288 | 293 | ## Handle class, no constructor, ConstructOnLoad = false, no loadobj/saveobj, vector
|
289 |
| -%!test |
| 294 | +%!testif HAVE_ZLIB |
290 | 295 | %! obj = regular_handle_class ();
|
291 | 296 | %! obj(2) = regular_handle_class ();
|
292 | 297 | %! obj(3) = obj(1);
|
|
306 | 311 | %! end_unwind_protect
|
307 | 312 |
|
308 | 313 | ## Constructor, ConstructOnLoad = false, Transient property
|
309 |
| -%!test |
| 314 | +%!testif HAVE_ZLIB |
310 | 315 | %! obj = transient_property_class ();
|
311 | 316 | %! obj.a = 1;
|
312 | 317 | %! obj.transient_property = 6;
|
|
323 | 328 | %! end_unwind_protect
|
324 | 329 |
|
325 | 330 | ## Constructor, ConstructOnLoad = true, Transient property, no loadobj/saveobj
|
326 |
| -%!test |
| 331 | +%!testif HAVE_ZLIB |
327 | 332 | %! obj = regular_class_construct_on_load ();
|
328 | 333 | %! obj.a = 10;
|
329 | 334 | %! obj.f = 16;
|
|
0 commit comments