Mercurial > hg > octave-lyh
annotate test/test_unwind.m @ 14131:c3309e1ec50d stable
test: Use Octave coding and spacing conventions for fixed test scripts
* build_bc_overload_tests.sh, build_bc_overloads_expected.m,
build_sparse_tests.sh, test_args.m, test_contin.m, test_diag_perm.m,
test_error.m, test_eval-catch.m, test_for.m, test_func.m, test_global.m,
test_if.m, test_index.m, test_io.m, test_logical_index.m, test_null_assign.m,
test_parser.m, test_prefer.m, test_range.m, test_recursion.m, test_return.m,
test_slice.m, test_struct.m, test_switch.m, test_system.m, test_transpose.m,
test_try.m, test_unwind.m, test_while.m:
Use Octave coding and spacing conventions for fixed test scripts.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 01 Jan 2012 20:04:52 -0800 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
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/unwind/unwind-1.m |
20 %!function y = f (x) | |
21 %! global g; | |
22 %! save_g = g; | |
23 %! unwind_protect | |
24 %! g = 0; | |
25 %! y = g; | |
26 %! [1,2;x]; | |
27 %! g = 1; | |
28 %! y = [y, g]; | |
29 %! unwind_protect_cleanup | |
30 %! g = save_g; | |
31 %! y = [y, g]; | |
32 %! end_unwind_protect | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
33 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 %! |
5590 | 35 %!test |
36 %! global g = -1; | |
37 %! y = f ([3,4]); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
38 %! assert (y, [0,1,-1]); |
5590 | 39 |
40 %% test/octave.test/unwind/unwind-2.m | |
41 %!function y = f (x) | |
42 %! global g; | |
43 %! save_g = g; | |
44 %! unwind_protect | |
45 %! g = 0; | |
46 %! y = g; | |
47 %! [1,2;x]; | |
48 %! g = 1; | |
49 %! y = [y, g]; | |
50 %! unwind_protect_cleanup | |
51 %! g = save_g; | |
52 %! y = [y, g]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
53 %! assert (y, [0,-1]); |
5590 | 54 %! end_unwind_protect |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
55 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
56 %! |
5590 | 57 %!test |
58 %! global g = -1; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
59 %! fail ("y = f (3);", "mismatch"); |
5590 | 60 |