annotate scripts/testfun/assert.m @ 11563:3c6e8aaa9555

Grammarcheck m-files before 3.4 release.
author Rik <octave@nomad.inbox5.com>
date Tue, 18 Jan 2011 20:55:01 -0800
parents fd0a3ac60b0e
children c792872f8942
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
1 ## Copyright (C) 2000-2011 Paul Kienzle
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
2 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
3 ## This file is part of Octave.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
4 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
6 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
8 ## your option) any later version.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
9 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
13 ## General Public License for more details.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
14 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
18
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} assert (@var{cond})
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
21 ## @deftypefnx {Function File} {} assert (@var{cond}, @var{errmsg}, @dots{})
9313
330672f4daaa fix texinfo bug
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9051
diff changeset
22 ## @deftypefnx {Function File} {} assert (@var{cond}, @var{msg_id}, @var{errmsg}, @dots{})
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
23 ## @deftypefnx {Function File} {} assert (@var{observed}, @var{expected})
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
24 ## @deftypefnx {Function File} {} assert (@var{observed}, @var{expected}, @var{tol})
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
25 ##
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8989
diff changeset
26 ## Produces an error if the condition is not met. @code{assert} can be
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
27 ## called in three different ways.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
28 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
29 ## @table @code
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
30 ## @item assert (@var{cond})
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
31 ## @itemx assert (@var{cond}, @var{errmsg}, @dots{})
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
32 ## @itemx assert (@var{cond}, @var{msg_id}, @var{errmsg}, @dots{})
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
33 ## Called with a single argument @var{cond}, @code{assert} produces an
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8989
diff changeset
34 ## error if @var{cond} is zero. If called with a single argument a
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8989
diff changeset
35 ## generic error message. With more than one argument, the additional
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
36 ## arguments are passed to the @code{error} function.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
37 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
38 ## @item assert (@var{observed}, @var{expected})
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8989
diff changeset
39 ## Produce an error if observed is not the same as expected. Note that
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
40 ## observed and expected can be strings, scalars, vectors, matrices,
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
41 ## lists or structures.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
42 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
43 ## @item assert(@var{observed}, @var{expected}, @var{tol})
7027
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
44 ## Accept a tolerance when comparing numbers.
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
45 ## If @var{tol} is positive use it as an absolute tolerance, will produce an
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
46 ## error if
7027
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
47 ## @code{abs(@var{observed} - @var{expected}) > abs(@var{tol})}.
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
48 ## If @var{tol} is negative use it as a relative tolerance, will produce an
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
49 ## error if
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
50 ## @code{abs(@var{observed} - @var{expected}) > abs(@var{tol} *
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
51 ## @var{expected})}. If @var{expected} is zero @var{tol} will always be used as
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
52 ## an absolute tolerance.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
53 ## @end table
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5589
diff changeset
54 ## @seealso{test}
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
55 ## @end deftypefn
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
56
8202
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7770
diff changeset
57 ## FIXME: Output throttling: don't print out the entire 100x100 matrix,
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7770
diff changeset
58 ## but instead give a summary; don't print out the whole list, just
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7770
diff changeset
59 ## say what the first different element is, etc. To do this, make
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7770
diff changeset
60 ## the message generation type specific.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6455
diff changeset
61
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
62 function assert (cond, varargin)
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6455
diff changeset
63
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6455
diff changeset
64 in = deblank (argn(1,:));
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6455
diff changeset
65 for i = 2:rows (argn)
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7151
diff changeset
66 in = cstrcat (in, ",", deblank (argn(i,:)));
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7027
diff changeset
67 endfor
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7151
diff changeset
68 in = cstrcat ("(", in, ")");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
69
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
70 if (nargin == 1 || (nargin > 1 && islogical (cond) && ischar (varargin{1})))
9841
6f1ea8241c99 make isnumeric yield false on logicals
Jaroslav Hajek <highegg@gmail.com>
parents: 9448
diff changeset
71 if ((! isnumeric (cond) && ! islogical (cond)) || ! all (cond(:)))
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
72 if (nargin == 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
73 ## Say which elements failed?
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
74 error ("assert %s failed", in);
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
75 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
76 error (varargin{:});
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
77 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
78 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
79 else
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
80 if (nargin < 2 || nargin > 3)
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
81 print_usage ();
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
82 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
83
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
84 expected = varargin {1};
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
85 if (nargin < 3)
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
86 tol = 0;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
87 else
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
88 tol = varargin {2};
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
89 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
90
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
91 if (exist ("argn") == 0)
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
92 argn = " ";
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
93 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
94
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
95 coda = "";
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
96 iserror = 0;
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
97
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
98
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
99 if (ischar (expected))
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
100 iserror = (! ischar (cond) || ! strcmp (cond, expected));
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
101
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
102 elseif (iscell (expected))
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
103 if (! iscell (cond) || any (size (cond) != size (expected)))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
104 iserror = 1;
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
105 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
106 try
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
107 for i = 1:length (expected(:))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
108 assert (cond{i}, expected{i}, tol);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
109 endfor
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
110 catch
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
111 iserror = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
112 end_try_catch
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
113 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
114
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
115 elseif (isstruct (expected))
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
116 if (! isstruct (cond) || any (size (cond) != size (expected))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
117 || rows (fieldnames (cond)) != rows (fieldnames (expected)))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
118 iserror = 1;
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
119 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
120 try
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
121 empty = numel (cond) == 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
122 normal = numel (cond) == 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
123 for [v, k] = cond
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
124 if (! isfield (expected, k))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
125 error ();
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
126 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
127 if (empty)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
128 v = cell (1, 0);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
129 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
130 if (normal)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
131 v = {v};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
132 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
133 v = v(:)';
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
134 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
135 assert (v, {expected.(k)}, tol);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
136 endfor
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
137 catch
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
138 iserror = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
139 end_try_catch
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
140 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
141
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
142 elseif (ndims (cond) != ndims (expected)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9841
diff changeset
143 || any (size (cond) != size (expected)))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
144 iserror = 1;
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
145 coda = "Dimensions don't match";
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
146
9447
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
147 else
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
148 if (nargin < 3)
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
149 ## Without explicit tolerance, be more strict.
9448
cb4a4119a21a Fix string comparison bug in assert.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9447
diff changeset
150 if (! strcmp(class (cond), class (expected)))
9447
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
151 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
152 coda = cstrcat ("Class ", class (cond), " != ", class (expected));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
153 elseif (isnumeric (cond))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
154 if (issparse (cond) != issparse (expected))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
155 if (issparse (cond))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
156 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
157 coda = "sparse != non-sparse";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
158 else
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
159 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
160 coda = "non-sparse != sparse";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
161 endif
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
162 elseif (iscomplex (cond) != iscomplex (expected))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
163 if (iscomplex (cond))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
164 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
165 coda = "complex != real";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
166 else
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
167 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
168 coda = "real != complex";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
169 endif
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
170 endif
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
171 endif
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
172 endif
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
173
9447
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
174 if (! iserror)
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
175 ## Numeric.
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
176 A = cond(:);
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
177 B = expected(:);
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
178 ## Check exceptional values.
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
179 if (any (isna (A) != isna (B)))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
180 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
181 coda = "NAs don't match";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
182 elseif (any (isnan (A) != isnan (B)))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
183 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
184 coda = "NaNs don't match";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
185 ## Try to avoid problems comparing strange values like Inf+NaNi.
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
186 elseif (any (isinf (A) != isinf (B))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
187 || any (A(isinf (A) & ! isnan (A)) != B(isinf (B) & ! isnan (B))))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
188 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
189 coda = "Infs don't match";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
190 else
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
191 ## Check normal values.
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
192 A = A(finite (A));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
193 B = B(finite (B));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
194 if (tol == 0)
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
195 err = any (A != B);
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
196 errtype = "values do not match";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
197 elseif (tol >= 0)
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
198 err = max (abs (A - B));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
199 errtype = "maximum absolute error %g exceeds tolerance %g";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
200 else
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
201 abserr = max (abs (A(B == 0)));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
202 A = A(B != 0);
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
203 B = B(B != 0);
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
204 relerr = max (abs (A - B) ./ abs (B));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
205 err = max ([abserr; relerr]);
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
206 errtype = "maximum relative error %g exceeds tolerance %g";
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
207 endif
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
208 if (err > abs (tol))
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
209 iserror = 1;
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
210 coda = sprintf (errtype, err, abs (tol));
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
211 endif
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
212 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
213 endif
9447
bb2ae2210e37 relax assert for exact matches
Jaroslav Hajek <highegg@gmail.com>
parents: 9313
diff changeset
214
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
215 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
216
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
217 if (! iserror)
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
218 return;
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
219 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
220
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8325
diff changeset
221 ## Pretty print the "expected but got" info, trimming leading and
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8325
diff changeset
222 ## trailing "\n".
7770
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
223 str = disp (expected);
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
224 idx = find (str != "\n");
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
225 if (! isempty (idx))
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
226 str = str(idx(1):idx(end));
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
227 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
228 str2 = disp (cond);
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
229 idx = find (str2 != "\n");
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
230 if (! isempty (idx))
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
231 str2 = str2 (idx(1):idx(end));
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
232 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
233 msg = cstrcat ("assert ", in, " expected\n", str, "\nbut got\n", str2);
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
234 if (! isempty (coda))
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
235 msg = cstrcat (msg, "\n", coda);
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
236 endif
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
237 error ("%s", msg);
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
238 ## disp (msg);
c6a1a217ac3c Compatibility fix for assert
David Bateman <dbateman@free.fr>
parents: 7703
diff changeset
239 ## error ("assertion failed");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
240 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
241 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
242
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
243 ## empty
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
244 %!assert([])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
245 %!assert(zeros(3,0),zeros(3,0))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
246 %!error assert(zeros(3,0),zeros(0,2))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
247 %!error assert(zeros(3,0),[])
6455
e68b6921b221 [project @ 2007-03-26 16:02:04 by jwe]
jwe
parents: 6392
diff changeset
248 %!fail("assert(zeros(2,0,2),zeros(2,0))", "Dimensions don't match")
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
249
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
250 ## conditions
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
251 %!assert(isempty([]))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
252 %!assert(1)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
253 %!error assert(0)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
254 %!assert(ones(3,1))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
255 %!assert(ones(1,3))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
256 %!assert(ones(3,4))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
257 %!error assert([1,0,1])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
258 %!error assert([1;1;0])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
259 %!error assert([1,0;1,1])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
260
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
261 ## vectors
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
262 %!assert([1,2,3],[1,2,3]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
263 %!assert([1;2;3],[1;2;3]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
264 %!error assert([2;2;3],[1;2;3]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
265 %!error assert([1,2,3],[1;2;3]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
266 %!error assert([1,2],[1,2,3]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
267 %!error assert([1;2;3],[1;2]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
268 %!assert([1,2;3,4],[1,2;3,4]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
269 %!error assert([1,4;3,4],[1,2;3,4])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
270 %!error assert([1,3;2,4;3,5],[1,2;3,4])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
271
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
272 ## exceptional values
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
273 %!assert([NaN, NA, Inf, -Inf, 1+eps, eps],[NaN, NA, Inf, -Inf, 1, 0],eps)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
274 %!error assert(NaN, 1)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
275 %!error assert(NA, 1)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
276 %!error assert(-Inf, Inf)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
277
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
278 ## scalars
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
279 %!error assert(3, [3,3; 3,3])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
280 %!error assert([3,3; 3,3], 3)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
281 %!assert(3, 3);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
282 %!assert(3+eps, 3, eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
283 %!assert(3, 3+eps, eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
284 %!error assert(3+2*eps, 3, eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
285 %!error assert(3, 3+2*eps, eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
286
7027
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
287 ## must give a little space for floating point errors on relative
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
288 %!assert(100+100*eps, 100, -2*eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
289 %!assert(100, 100+100*eps, -2*eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
290 %!error assert(100+300*eps, 100, -2*eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
291 %!error assert(100, 100+300*eps, -2*eps);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
292 %!error assert(3, [3,3]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
293 %!error assert(3,4);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
294
7027
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
295 ## test relative vs. absolute tolerances
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
296 %!test assert (0.1+eps, 0.1, 2*eps); # accept absolute
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
297 %!error assert (0.1+eps, 0.1, -2*eps); # fail relative
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
298 %!test assert (100+100*eps, 100, -2*eps); # accept relative
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
299 %!error assert (100+100*eps, 100, 2*eps); # fail absolute
3e2a59c78b9d [project @ 2007-10-15 08:22:54 by dbateman]
dbateman
parents: 7017
diff changeset
300
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
301 ## structures
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
302 %!shared x,y
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
303 %! x.a = 1; x.b=[2, 2];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
304 %! y.a = 1; y.b=[2, 2];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
305 %!assert (x,y)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
306 %!test y.b=3;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
307 %!error assert (x,y)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
308 %!error assert (3, x);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
309 %!error assert (x, 3);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
310
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
311 ## check usage statements
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
312 %!error assert
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
313 %!error assert(1,2,3,4,5)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
314
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
315 ## strings
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
316 %!assert("dog","dog")
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
317 %!error assert("dog","cat")
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
318 %!error assert("dog",3);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
319 %!error assert(3,"dog");