Mercurial > hg > octave-lojdl
annotate test/eval-catch.tst @ 17466:cf5a8fccfc63
area.m: Overhaul function to fix color cycling.
* scripts/plot/area.m: Fix color cycling. Fix input validation and make it
more precise. Add %!error tests for input validation.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 18 Sep 2013 19:43:09 -0700 |
parents | 333243133364 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14131
diff
changeset
|
1 ## Copyright (C) 2006-2012 John W. Eaton |
7016 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
5590 | 19 %!test |
20 %! eval ("clear a; a;", ""); | |
21 | |
22 %!test | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
23 %! eval ("", "error ('Should not get here');"); |
5590 | 24 |
25 %!test | |
26 %! eval ("clear a; a; x = 0;", "x = 1;"); | |
27 %! assert (x, 1); | |
28 | |
29 %!test | |
30 %! eval ("clear a; a; str = '';", "str=lasterr;"); | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
31 %! assert (lasterr()(1:13), "'a' undefined"); |
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
32 %! assert (str(1:13), "'a' undefined"); |
5590 | 33 |
34 %!test | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
35 %! eval ("error ('user-defined error'); str = '';", "str = lasterr;"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
36 %! assert (lasterr()(1:18), "user-defined error"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
37 %! assert (str(1:18), "user-defined error"); |
5590 | 38 |
39 %!function ms = mangle (s) | |
40 %! ## Wrap angle brackets around S. | |
16996
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16939
diff
changeset
|
41 %! ms = ["<" s ">"]; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
42 %!endfunction |
5590 | 43 %!test |
44 %! eval ("clear a; a; str='';", "str = mangle (lasterr);"); | |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
45 %! assert (mangle (lasterr)(1:14), "<'a' undefined"); |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
46 %! assert (str(1:14), "<'a' undefined"); |
5590 | 47 |
48 %!test | |
49 %! eval ("eval (\"clear a; a;str1='';\", \"str1=lasterr;\"); clear b; b; str2='';", | |
50 %! "str2 = lasterr;"); | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
51 %! assert (str1(1:13), "'a' undefined"); |
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
52 %! assert (str2(1:13), "'b' undefined"); |
5590 | 53 |
54 %!test | |
55 %! eval ("clear a; a; str1='';", | |
56 %! "eval (\"clear b; b; str2='';\", \"str2=lasterr;\"); str1=lasterr;"); | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
57 %! assert (str1(1:13), "'b' undefined"); |
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
58 %! assert (str2(1:13), "'b' undefined"); |
5590 | 59 |
60 %!test | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
61 %! eval ("eval (\"clear a; a; str='';\",\"error (cstrcat (\\\"rethrow: \\\", lasterr));str='';\");", |
5590 | 62 %! "str=lasterr;"); |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
63 %! assert (str(1:22), "rethrow: 'a' undefined"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 |