Mercurial > hg > octave-nkf
annotate test/unwind.tst @ 20799:e34692daf663
Extend parser to accept '_' in numbers.
* NEWS: Announce change.
* lex.ll: Define NUMBER to be a NUMREAL (real number) or NUMHEX (hex number).
Define NUMREAL to begin with a digit (D) followed by more digits or an '_'.
Define NUMHEX to begin with 0[xX], a hex digit (a-fA-F0-9), followed by '_' or
more hex digits.
Define EXPON to have a digit (D) followed by more digits or an '_'.
* lex.ll (octave_base_lexer::handle_number): Strip out any underscores before
processing number with sscanf.
* parser.tst: Add tests for new behavior.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 05 Oct 2015 14:05:58 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2006-2015 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 %!function y = f (x) |
20 %! global g; | |
21 %! save_g = g; | |
22 %! unwind_protect | |
23 %! g = 0; | |
24 %! y = g; | |
25 %! [1,2;x]; | |
26 %! g = 1; | |
27 %! y = [y, g]; | |
28 %! unwind_protect_cleanup | |
29 %! g = save_g; | |
30 %! y = [y, g]; | |
17309
5a65b2cc9508
test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
31 %! end # "end" is part of test, check not using "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
|
32 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
33 %! |
5590 | 34 %!test |
35 %! global g = -1; | |
36 %! 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
|
37 %! assert (y, [0,1,-1]); |
5590 | 38 |
39 %!function y = f (x) | |
40 %! global g; | |
41 %! save_g = g; | |
42 %! unwind_protect | |
43 %! g = 0; | |
44 %! y = g; | |
45 %! [1,2;x]; | |
46 %! g = 1; | |
47 %! y = [y, g]; | |
48 %! unwind_protect_cleanup | |
49 %! g = save_g; | |
50 %! 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
|
51 %! assert (y, [0,-1]); |
5590 | 52 %! 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
|
53 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
54 %! |
5590 | 55 %!test |
56 %! 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
|
57 %! fail ("y = f (3);", "mismatch"); |
5590 | 58 |