annotate scripts/testfun/fail.m @ 20162:2645f9ef8c88 stable

doc: Update more docstrings to have one sentence summary as first line. Reviewed specfun, special-matrix, testfun, and time script directories. * scripts/specfun/expint.m, scripts/specfun/isprime.m, scripts/specfun/legendre.m, scripts/specfun/primes.m, scripts/specfun/reallog.m, scripts/specfun/realsqrt.m, scripts/special-matrix/gallery.m, scripts/special-matrix/hadamard.m, scripts/special-matrix/hankel.m, scripts/special-matrix/hilb.m, scripts/special-matrix/invhilb.m, scripts/special-matrix/magic.m, scripts/special-matrix/pascal.m, scripts/special-matrix/rosser.m, scripts/special-matrix/toeplitz.m, scripts/special-matrix/vander.m, scripts/special-matrix/wilkinson.m, scripts/testfun/assert.m, scripts/testfun/demo.m, scripts/testfun/example.m, scripts/testfun/fail.m, scripts/testfun/rundemos.m, scripts/testfun/runtests.m, scripts/testfun/speed.m, scripts/time/asctime.m, scripts/time/calendar.m, scripts/time/clock.m, scripts/time/ctime.m, scripts/time/datenum.m, scripts/time/datestr.m, scripts/time/datevec.m, scripts/time/etime.m, scripts/time/is_leap_year.m, scripts/time/now.m, scripts/time/weekday.m: Update more docstrings to have one sentence summary as first line.
author Rik <rik@octave.org>
date Sun, 03 May 2015 17:00:11 -0700
parents 64a2d4c87ecb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19015
diff changeset
1 ## Copyright (C) 2005-2015 Paul Kienzle
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
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.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
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.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
14 ##
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
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/>.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
18 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
19 ## Original version by Paul Kienzle distributed as free software in the
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6494
diff changeset
20 ## public domain.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
21
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
22 ## -*- texinfo -*-
12632
2dbac27e0e40 doc: miscellaneous touch-ups to documentation strings
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
23 ## @deftypefn {Function File} {} fail (@var{code})
2dbac27e0e40 doc: miscellaneous touch-ups to documentation strings
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
24 ## @deftypefnx {Function File} {} fail (@var{code}, @var{pattern})
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
25 ## @deftypefnx {Function File} {} fail (@var{code}, "warning")
14359
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
26 ## @deftypefnx {Function File} {} fail (@var{code}, "warning", @var{pattern})
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
27 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
28 ## Return true if @var{code} fails with an error message matching
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
29 ## @var{pattern}, otherwise produce an error.
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
30 ##
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
31 ## @var{code} must be in the form of a string that is passed to the Octave
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
32 ## interpreter via the @code{evalin} function, i.e., a (quoted) string constant
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
33 ## or a string variable.
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
34 ##
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
35 ## Note that if @var{code} runs successfully, rather than failing, the error
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
36 ## printed is:
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 ## @example
16190
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
39 ## expected error <.> but got none
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
40 ## @end example
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
41 ##
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
42 ## If called with two arguments, the return value will be true only if
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
43 ## @var{code} fails with an error message containing @var{pattern}
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
44 ## (case sensitive). If the code fails with a different error than the one
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
45 ## specified in @var{pattern} then the message produced is:
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
46 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
47 ## @example
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
48 ## @group
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
49 ## expected <@var{pattern}>
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
50 ## but got <text of actual error>
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
51 ## @end group
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
52 ## @end example
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
53 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
54 ## The angle brackets are not part of the output.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
55 ##
20162
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
56 ## When called with the @qcode{"warning"} option @code{fail} will produce an
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
57 ## error if executing the code produces no warning.
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
58 ## @seealso{assert, error}
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
59 ## @end deftypefn
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
60
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
61 ## Author: Paul Kienzle <pkienzle@users.sf.net>
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
62
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
63 function retval = fail (code, pattern, warning_pattern)
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
64
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
65 if (nargin < 1 || nargin > 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5589
diff changeset
66 print_usage ();
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
67 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
68
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
69 ## Parse input arguments
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
70 test_warning = false;
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
71 if (nargin == 1)
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
72 pattern = "";
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
73 elseif (nargin == 2 && ! strcmp (pattern, "warning"))
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
74 ## Normal error test
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
75 elseif (nargin >= 2 && strcmp (pattern, "warning"))
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
76 test_warning = true;
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
77 if (nargin == 2)
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
78 pattern = "";
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
79 else
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
80 pattern = warning_pattern;
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
81 endif
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
82 else
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
83 print_usage ();
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
84 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
85
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
86 ## Match any nonempty message
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
87 if (isempty (pattern))
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
88 pattern = ".";
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
89 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
90
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
91 ## Allow assert (fail ())
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
92 if (nargout)
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
93 retval = true;
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
94 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
95
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
96 if (test_warning)
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
97 ## Perform the warning test.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
98 ## Clear old warnings.
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
99 lastwarn ("");
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
100 ## Make sure warnings are turned on.
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
101 wstate = warning ("query", "quiet");
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
102 warning ("on", "quiet");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
103 try
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
104 evalin ("caller", [code ";"]);
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
105 ## Retrieve new warnings.
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
106 warn = lastwarn ();
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
107 warning (wstate.state, "quiet");
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
108 if (isempty (warn))
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
109 msg = sprintf ("expected warning <%s> but got none", pattern);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
110 else
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
111 if (! isempty (regexp (warn, pattern, "once")))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9051
diff changeset
112 return;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9051
diff changeset
113 endif
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
114 msg = sprintf ("expected warning <%s>\nbut got <%s>", pattern, warn);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
115 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
116 catch
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
117 warning (wstate.state, "quiet");
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
118 err = lasterr ();
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
119 msg = sprintf ("expected warning <%s>\nbut got error <%s>", pattern, err);
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
120 end_try_catch
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
121
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
122 else
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
123 ## Perform the error test.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
124 try
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
125 evalin ("caller", [code ";"]);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
126 msg = sprintf ("expected error <%s> but got none", pattern);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
127 catch
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
128 err = lasterr ();
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
129 if (! isempty (regexp (err, pattern, "once")))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9051
diff changeset
130 return;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
131 endif
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
132 msg = sprintf ("expected error <%s>\nbut got <%s>", pattern, err);
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
133 end_try_catch
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
134 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
135
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
136 ## If we get here, then code didn't fail or error didn't match.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6046
diff changeset
137 error (msg);
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 7151
diff changeset
138
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
139 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
140
13066
756af8385e26 codesprint: Tests for fail.m
Rik <octave@nomad.inbox5.com>
parents: 12632
diff changeset
141
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
142 %!fail ("[1,2]*[2,3]", "nonconformant")
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
143 %!fail ("fail ('[1,2]*[2;3]', 'nonconformant')", "expected error <nonconformant> but got none")
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
144 %!fail ("fail ('[1,2]*[2,3]', 'usage:')", "expected error <usage:>\nbut got.*nonconformant")
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
145 %!fail ("warning ('test warning')", "warning", "test warning");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
146
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
147 #%!fail ("warning ('next test')",'warning','next test'); # only allowed one warning test?!?
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
148
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
149 ## Test that fail() itself will generate an error
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
150 %!error <expected error> fail ("1")
19935
2d5cbb6ac845 fail.m: Use internal variable name in BIST test (bug #44525).
Rik <rik@octave.org>
parents: 19833
diff changeset
151 %!error <'__a__' undefined> fail ("__a__*[2;3]", "nonconformant")
2d5cbb6ac845 fail.m: Use internal variable name in BIST test (bug #44525).
Rik <rik@octave.org>
parents: 19833
diff changeset
152 %!error <expected error .usage:> fail ("__a__*[2,3]", "usage:")
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
153 %!error <warning failure> fail ("warning ('warning failure')", "warning", "success")
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
154
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
155 ## Test input validation
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
156 %!error fail ()
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
157 %!error fail (1,2,3,4)
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 19935
diff changeset
158 %!error fail (1, "nowarning", "foo")
19015
ffa20d287355 fail.m: Overhaul function and return logical true rather than double (1).
Rik <rik@octave.org>
parents: 17744
diff changeset
159