Mercurial > octave-nkf
comparison test/parser.tst @ 20624:7c0e10f035bd
Extend parser to accept binary constants that begin with '0b' or '0B'.
* NEWS: Announce change:
* lex.ll: Define NUMBIN to be 0[bB] followed by 0,1, or '_'.
Define NUMBER to be NUMREAL|NUMHEX|NUMBIN.
*lex.ll (looks_like_bin): New function to detect 0[bB] prefix.
*lex.ll (handle_numbe): Call looks_like_bin() and if found then convert
binary string to double.
* parser.tst: Add tests for new behavior.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 09 Oct 2015 18:52:58 -0700 |
parents | e34692daf663 |
children |
comparison
equal
deleted
inserted
replaced
20623:e34692daf663 | 20624:7c0e10f035bd |
---|---|
280 %!assert (.123_456, .123456) | 280 %!assert (.123_456, .123456) |
281 %!assert (123_456.123_456, 123456.123456) | 281 %!assert (123_456.123_456, 123456.123456) |
282 %!assert (0xAB_CD, 43981) | 282 %!assert (0xAB_CD, 43981) |
283 %!assert (2e0_1, 20); | 283 %!assert (2e0_1, 20); |
284 | 284 |
285 ## Test binary constants | |
286 %!assert (0b101, 5) | |
287 %!assert (0B1100_0001, 0xC1) | |
288 %!assert (class (0b1), "double") | |
289 | |
285 ## Test creation of anonymous functions | 290 ## Test creation of anonymous functions |
286 | 291 |
287 %!test | 292 %!test |
288 %! af_in_cell = {@(x) [1 2]}; | 293 %! af_in_cell = {@(x) [1 2]}; |
289 %! assert (af_in_cell{1}(), [1, 2]); | 294 %! assert (af_in_cell{1}(), [1, 2]); |