Mercurial > octave-nkf
comparison scripts/testfun/assert.m @ 20089:cbba639b956b
fail if single argument to assert is empty. (bug #44793)
* assert.m: Also fail for single empty arguments. New tests.
Fix test for assert ([]).
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 09 Apr 2015 13:54:07 -0400 |
parents | 9fc020886ae9 |
children | 2645f9ef8c88 |
comparison
equal
deleted
inserted
replaced
20088:ac59136f1f10 | 20089:cbba639b956b |
---|---|
74 if (call_depth == 0) | 74 if (call_depth == 0) |
75 errmsg = ""; | 75 errmsg = ""; |
76 endif | 76 endif |
77 | 77 |
78 if (nargin == 1 || (nargin > 1 && islogical (cond) && ischar (varargin{1}))) | 78 if (nargin == 1 || (nargin > 1 && islogical (cond) && ischar (varargin{1}))) |
79 if ((! isnumeric (cond) && ! islogical (cond)) || ! all (cond(:))) | 79 if ((! isnumeric (cond) && ! islogical (cond)) |
80 || isempty (cond) || ! all (cond(:))) | |
80 if (nargin == 1) | 81 if (nargin == 1) |
81 ## Perhaps, say which elements failed? | 82 ## Perhaps, say which elements failed? |
82 argin = ["(" strjoin(cellstr (argn), ",") ")"]; | 83 argin = ["(" strjoin(cellstr (argn), ",") ")"]; |
83 error ("assert %s failed", argin); | 84 error ("assert %s failed", argin); |
84 else | 85 else |
402 | 403 |
403 endfunction | 404 endfunction |
404 | 405 |
405 | 406 |
406 ## empty input | 407 ## empty input |
407 %!assert ([]) | 408 %!error assert ([]) |
409 %!error assert ("") | |
410 %!error assert ({}) | |
411 %!error assert (struct ([])) | |
408 %!assert (zeros (3,0), zeros (3,0)) | 412 %!assert (zeros (3,0), zeros (3,0)) |
409 %!error <O\(3x0\)\s+E\(0x2\)> assert (zeros (3,0), zeros (0,2)) | 413 %!error <O\(3x0\)\s+E\(0x2\)> assert (zeros (3,0), zeros (0,2)) |
410 %!error <Dimensions don't match> assert (zeros (3,0), []) | 414 %!error <Dimensions don't match> assert (zeros (3,0), []) |
411 %!error <Dimensions don't match> assert (zeros (2,0,2), zeros (2,0)) | 415 %!error <Dimensions don't match> assert (zeros (2,0,2), zeros (2,0)) |
412 | 416 |