Mercurial > octave-nkf
comparison test/try.tst @ 16030:1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
* Use - instead of _ for .tst file names. Fix all file lists in
module.mk and Makefile.am files.
* __run_test_suite__.m: Adapt to new naming convention.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 09 Feb 2013 21:35:55 -0500 |
parents | test/test_try.m@d174210ce1ec |
children | 6fe6ac8bbfdb |
comparison
equal
deleted
inserted
replaced
16029:b8157404614f | 16030:1af8d21608b7 |
---|---|
1 ## Copyright (C) 2006-2012 John W. Eaton | |
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 | |
19 %% test/octave.test/try/try-1.m | |
20 %!test | |
21 %! try | |
22 %! catch | |
23 %! error ("Shoudn't get here"); | |
24 %! end_try_catch | |
25 | |
26 %% test/octave.test/try/try-2.m | |
27 %!test | |
28 %! try | |
29 %! clear a; | |
30 %! a; | |
31 %! catch | |
32 %! end_try_catch | |
33 %! a = 1; | |
34 %! assert (a,1); | |
35 | |
36 %% test/octave.test/try/try-3.m | |
37 %!test | |
38 %! clear x; | |
39 %! try | |
40 %! clear a; | |
41 %! a; | |
42 %! x = 1; | |
43 %! catch | |
44 %! end_try_catch | |
45 %! a = 2; | |
46 %! assert (!exist ('x')); | |
47 %! assert (a,2); | |
48 | |
49 %% test/octave.test/try/try-4.m | |
50 %!test | |
51 %! try | |
52 %! clear a; | |
53 %! a; | |
54 %! catch | |
55 %! x = 1; | |
56 %! end_try_catch | |
57 %! assert (exist ('x')); | |
58 | |
59 %% test/octave.test/try/try-5.m | |
60 %!test | |
61 %! try | |
62 %! clear a; | |
63 %! a; | |
64 %! error ("Shoudn't get here"); | |
65 %! catch | |
66 %! assert (lasterr()(1:13), "'a' undefined"); | |
67 %! end_try_catch | |
68 %! assert (lasterr()(1:13), "'a' undefined"); | |
69 | |
70 %% test/octave.test/try/try-6.m | |
71 %!test | |
72 %! try | |
73 %! error ("user-defined error"); | |
74 %! catch | |
75 %! assert (lasterr, "user-defined error"); | |
76 %! end_try_catch | |
77 | |
78 %% test/octave.test/try/try-7.m | |
79 %!function ms = mangle (s) | |
80 %! ## Wrap angle brackets around S. | |
81 %! ms = cstrcat ("<", s, ">"); | |
82 %!endfunction | |
83 %!test | |
84 %! try | |
85 %! clear a; | |
86 %! a; | |
87 %! error ("Shoudn't get here"); | |
88 %! catch | |
89 %! assert (mangle (lasterr)(1:14), "<'a' undefined"); | |
90 %! end_try_catch | |
91 | |
92 %% test/octave.test/try/try-8.m | |
93 %!test | |
94 %! try | |
95 %! try | |
96 %! clear a; | |
97 %! a; | |
98 %! error ("Shoudn't get here"); | |
99 %! catch | |
100 %! assert (lasterr()(1:13), "'a' undefined"); | |
101 %! end_try_catch | |
102 %! clear b; | |
103 %! b; | |
104 %! error ("Shoudn't get here"); | |
105 %! catch | |
106 %! assert (lasterr()(1:13), "'b' undefined"); | |
107 %! end_try_catch | |
108 | |
109 %% test/octave.test/try/try-9.m | |
110 %!test | |
111 %! try | |
112 %! clear a; | |
113 %! a; | |
114 %! error ("Shoudn't get here"); | |
115 %! catch | |
116 %! try | |
117 %! assert (lasterr()(1:13), "'a' undefined"); | |
118 %! clear b; | |
119 %! b; | |
120 %! error ("Shoudn't get here"); | |
121 %! catch | |
122 %! assert (lasterr()(1:13), "'b' undefined"); | |
123 %! end_try_catch | |
124 %! end_try_catch | |
125 | |
126 %% test/octave.test/try/try-10.m | |
127 %!test | |
128 %! try | |
129 %! try | |
130 %! clear a; | |
131 %! a; | |
132 %! error ("Shoudn't get here"); | |
133 %! catch | |
134 %! error (cstrcat ("rethrow: ", lasterr)); | |
135 %! end_try_catch | |
136 %! catch | |
137 %! assert (lasterr()(1:22), "rethrow: 'a' undefined"); | |
138 %! end_try_catch | |
139 |