Mercurial > octave-nkf
comparison test/parser.tst @ 20623: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 | 7c0e10f035bd |
comparison
equal
deleted
inserted
replaced
20622:128414587af2 | 20623:e34692daf663 |
---|---|
273 %!test | 273 %!test |
274 %! a = 2; b = 5; c = 7; | 274 %! a = 2; b = 5; c = 7; |
275 %! assert (a += b *= c += 1, 42); | 275 %! assert (a += b *= c += 1, 42); |
276 %! assert (b == 40 && c == 8); | 276 %! assert (b == 40 && c == 8); |
277 | 277 |
278 ## Test extended number format which allows '_' as NOP character | |
279 %!assert (123_456, 123456) | |
280 %!assert (.123_456, .123456) | |
281 %!assert (123_456.123_456, 123456.123456) | |
282 %!assert (0xAB_CD, 43981) | |
283 %!assert (2e0_1, 20); | |
284 | |
278 ## Test creation of anonymous functions | 285 ## Test creation of anonymous functions |
279 | 286 |
280 %!test | 287 %!test |
281 %! af_in_cell = {@(x) [1 2]}; | 288 %! af_in_cell = {@(x) [1 2]}; |
282 %! assert (af_in_cell{1}(), [1, 2]); | 289 %! assert (af_in_cell{1}(), [1, 2]); |