Mercurial > hg > octave-thorsten
annotate test/test_try.m @ 15301:34ae358bd566 draft
* contributors.in: restored alphabetic order and removed a dublicate entry
author | Thorsten Liebig <Thorsten.Liebig@gmx.de> |
---|---|
date | Wed, 05 Sep 2012 16:59:33 +0200 |
parents | 72c96de7a403 |
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/octave.test/try/try-1.m |
20 %!test | |
21 %! try | |
22 %! catch | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
23 %! error ("Shoudn't get here"); |
5590 | 24 %! end_try_catch |
25 | |
26 %% test/octave.test/try/try-2.m | |
27 %!test | |
28 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
29 %! clear a; |
5590 | 30 %! a; |
31 %! catch | |
32 %! end_try_catch | |
33 %! a = 1; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 %! assert (a,1); |
5590 | 35 |
36 %% test/octave.test/try/try-3.m | |
37 %!test | |
38 %! clear x; | |
39 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
40 %! clear a; |
5590 | 41 %! a; |
42 %! x = 1; | |
43 %! catch | |
44 %! end_try_catch | |
45 %! a = 2; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
46 %! assert (!exist ('x')); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
47 %! assert (a,2); |
5590 | 48 |
49 %% test/octave.test/try/try-4.m | |
50 %!test | |
51 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
52 %! clear a; |
5590 | 53 %! a; |
54 %! catch | |
55 %! x = 1; | |
56 %! end_try_catch | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
57 %! assert (exist ('x')); |
5590 | 58 |
59 %% test/octave.test/try/try-5.m | |
60 %!test | |
61 %! try | |
62 %! clear a; | |
63 %! a; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 %! error ("Shoudn't get here"); |
5590 | 65 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
66 %! assert (lasterr()(1:13), "`a' undefined"); |
5590 | 67 %! end_try_catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
68 %! assert (lasterr()(1:13), "`a' undefined"); |
5590 | 69 |
70 %% test/octave.test/try/try-6.m | |
71 %!test | |
72 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
73 %! error ("user-defined error"); |
5590 | 74 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
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, ">"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
82 %!endfunction |
5590 | 83 %!test |
84 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
85 %! clear a; |
5590 | 86 %! a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
87 %! error ("Shoudn't get here"); |
5590 | 88 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
89 %! assert (mangle (lasterr)(1:14), "<`a' undefined"); |
5590 | 90 %! end_try_catch |
91 | |
92 %% test/octave.test/try/try-8.m | |
93 %!test | |
94 %! try | |
95 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
96 %! clear a; |
5590 | 97 %! a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
98 %! error ("Shoudn't get here"); |
5590 | 99 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
100 %! assert (lasterr()(1:13), "`a' undefined"); |
5590 | 101 %! end_try_catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
102 %! clear b; |
5590 | 103 %! b; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
104 %! error ("Shoudn't get here"); |
5590 | 105 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
106 %! assert (lasterr()(1:13), "`b' undefined"); |
5590 | 107 %! end_try_catch |
108 | |
109 %% test/octave.test/try/try-9.m | |
110 %!test | |
111 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
112 %! clear a; |
5590 | 113 %! a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
114 %! error ("Shoudn't get here"); |
5590 | 115 %! catch |
116 %! try | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
117 %! assert (lasterr()(1:13), "`a' undefined"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
118 %! clear b; |
5590 | 119 %! b; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
120 %! error ("Shoudn't get here"); |
5590 | 121 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
122 %! assert (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 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
130 %! clear a; |
5590 | 131 %! a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
132 %! error ("Shoudn't get here"); |
5590 | 133 %! catch |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
134 %! error (cstrcat ("rethrow: ", lasterr)); |
5590 | 135 %! end_try_catch |
136 %! catch | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
137 %! assert (lasterr()(1:22), "rethrow: `a' undefined"); |
5590 | 138 %! end_try_catch |
139 |