annotate test/try.tst @ 33596:96a203bc7e17 bytecode-interpreter tip

maint: Merge default to bytecode-interpreter
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Fri, 17 May 2024 22:49:58 -0400
parents 2e484f9f1f18
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
3 ## Copyright (C) 2006-2024 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
7 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
8 ## This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
14 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
19 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
20 ## You should have received a copy of the GNU General Public License
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
25
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
26 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
27 %! try
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
28 %! catch
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
29 %! error ("Shouldn't get here");
17309
5a65b2cc9508 test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents: 17283
diff changeset
30 %! end # "end" is part of test, check not using "end_try_catch"
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
31
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
32 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
33 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
34 %! clear a;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
35 %! a;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
36 %! catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
37 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
38 %! a = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
39 %! assert (a,1);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
40
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
41 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
42 %! clear x;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
43 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
44 %! clear a;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
45 %! a;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
46 %! x = 1;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
47 %! catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
48 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
49 %! a = 2;
28923
3f8e1fa0eed2 maint: Use space after '!' logical not operator.
Rik <rik@octave.org>
parents: 28916
diff changeset
50 %! assert (! exist ('x'));
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
51 %! assert (a,2);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
52
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
53 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
54 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
55 %! clear a;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
56 %! a;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
57 %! catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
58 %! x = 1;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
59 %! 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
60 %! assert (exist ('x'));
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
61
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
62 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
63 %! try
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
64 %! clear a;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
65 %! a;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
66 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
67 %! catch
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
68 %! assert (lasterr ()(1:13), "'a' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
69 %! end_try_catch
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
70 %! assert (lasterr ()(1:13), "'a' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
71
16215
6fe6ac8bbfdb test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
72 %!test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
73 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
74 %! error ("user-defined error");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
75 %! catch
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
76 %! assert (lasterr, "user-defined error");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
77 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
78
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
79 %!function ms = mangle (s)
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
80 %! ## Wrap angle brackets around S.
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16937
diff changeset
81 %! ms = ["<" 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
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
83 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
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
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
86 %! a;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
87 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
88 %! catch
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
89 %! assert (mangle (lasterr)(1:14), "<'a' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
90 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
91
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
92 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
93 %! try
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
94 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
95 %! clear a;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
96 %! a;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
97 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
98 %! catch
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
99 %! assert (lasterr ()(1:13), "'a' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
100 %! 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
101 %! clear b;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
102 %! b;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
103 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
104 %! catch
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
105 %! assert (lasterr ()(1:13), "'b' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
106 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
107
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
108 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
109 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
110 %! clear a;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
111 %! a;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
112 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
113 %! catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
114 %! try
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
115 %! assert (lasterr ()(1:13), "'a' undefined");
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
116 %! clear b;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
117 %! b;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
118 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
119 %! catch
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
120 %! assert (lasterr ()(1:13), "'b' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
121 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
122 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
123
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
124 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
125 %! try
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
126 %! try
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
127 %! clear a;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
128 %! a;
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
129 %! error ("Shouldn't get here");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
130 %! catch
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16937
diff changeset
131 %! error (["rethrow: " lasterr]);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
132 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
133 %! catch
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27957
diff changeset
134 %! assert (lasterr ()(1:22), "rethrow: 'a' undefined");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
135 %! end_try_catch
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
136
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
137 %!test
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
138 %! clear myerr;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
139 %! try
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
140 %! error ("user-defined error");
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
141 %! catch myerr
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
142 %! assert (myerr.message, "user-defined error");
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
143 %! end_try_catch
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
144
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
145 %!test
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
146 %! try
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
147 %! clear a;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
148 %! error ("user-defined error");
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
149 %! catch a=1;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
150 %! assert (lasterr, "user-defined error");
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
151 %! assert (a, 1);
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
152 %! end_try_catch
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
153
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
154 %!test
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
155 %! clear myerr1
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
156 %! clear myerr2
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
157 %! try
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
158 %! try
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
159 %! clear a;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
160 %! a;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
161 %! catch myerr1
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
162 %! error (myerr1);
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
163 %! end_try_catch
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
164 %! catch myerr2
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
165 %! assert (myerr1.message, myerr2.message);
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
166 %! assert (myerr1.identifier, myerr2.identifier);
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
167 %! end_try_catch
17283
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
168
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
169 %!test
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
170 %! x = 1;
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
171 %! try error ("foo"); catch x; assert (x.message, "foo"); end_try_catch
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
172
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
173 %!test
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
174 %! x = 1;
29864
e2e493712818 improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
175 %! try error ("foo"); catch x; end_try_catch
17283
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
176 %! assert (x.message, "foo");
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
177
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
178 %!test
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
179 %! x = 1;
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
180 %! try error ("foo"); catch, x; assert (x, 1); end_try_catch
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
181
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
182 %!test
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
183 %! x = 1;
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
184 %! try error ("foo"); catch; x; assert (x, 1); end_try_catch
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
185
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
186 %!test
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
187 %! x = 1;
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
188 %! try error ("foo"); catch
e6c0ac8ce5b6 eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents: 17249
diff changeset
189 %! x; assert (x, 1); end_try_catch