Mercurial > hg > octave-lyh
annotate test/test_try.m @ 11529:f98f925d8e5c
Add undocumented function erfcx to documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 14 Jan 2011 11:59:59 -0800 |
parents | fd0a3ac60b0e |
children | c3309e1ec50d |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2006-2011 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/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 | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
66 %! assert (strcmp(lasterr()(1:13), "`a' undefined")) |
5590 | 67 %! end_try_catch |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
68 %! assert (strcmp(lasterr()(1:13), "`a' undefined")) |
5590 | 69 |
70 %% test/octave.test/try/try-6.m | |
71 %!test | |
72 %! try | |
73 %! error ("user-defined error") | |
74 %! catch | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
75 %! assert(lasterr,"user-defined error"); |
5590 | 76 %! end_try_catch |
77 | |
78 %% test/octave.test/try/try-7.m | |
79 %!function ms = mangle (s) | |
80 %! ## Wrap angle brackets around S. | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
81 %! ms = cstrcat ("<", s, ">"); |
5590 | 82 %!test |
83 %! try | |
84 %! clear a | |
85 %! a; | |
86 %! error("Shoudn't get here"); | |
87 %! catch | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
88 %! assert(strcmp(mangle (lasterr)(1:14),"<`a' undefined")) |
5590 | 89 %! end_try_catch |
90 | |
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 | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
100 %! assert(strcmp(lasterr()(1:13), "`a' undefined")) |
5590 | 101 %! end_try_catch |
102 %! clear b | |
103 %! b; | |
104 %! error("Shoudn't get here"); | |
105 %! catch | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
106 %! assert(strcmp(lasterr()(1:13), "`b' undefined")) |
5590 | 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 | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
117 %! assert(strcmp(lasterr()(1:13), "`a' undefined")) |
5590 | 118 %! clear b |
119 %! b; | |
120 %! error("Shoudn't get here"); | |
121 %! catch | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
122 %! assert(strcmp(lasterr()(1:13), "`b' undefined")) |
5590 | 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 | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
134 %! error(cstrcat("rethrow: ",lasterr)); |
5590 | 135 %! end_try_catch |
136 %! catch | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
137 %! assert(strcmp(lasterr()(1:22), "rethrow: `a' undefined")) |
5590 | 138 %! end_try_catch |
139 |