lci/test/1.3-Tests/7-Operators
D.E. Akers f5f5edb889 relax numeric conversions from string
The spec does not establish any particular constraints to observe in
casting from `YARN` to `NUMB(A)R`. Presently, `lci` checks that the
string consists only of numeric characters prior to attempting the
conversion, halting with an error if it's found not to be the case.

This behavior is often more inconvenient than helpful. Many numeric
strings encountered in the wild are "roughly numeric", and it would be
wise to account for this observation. As a simple example, a user may
be prompted to input a number; in the case of their inadvertently
providing leading or trailing whitespace, a naive program will crash
rather than gracefully extracting the otherwise sensible input.

This patch removes the `isDecString()` function and instead leverages
the `strtoll()` and `strtof()` functions to handle casts from `YARN`
to `NUMBR` and `NUMBAR`, respectively. Thus, strings to be converted
are permitted to contain leading whitespace, and trailing non-numeric
characters are ignored. Additionally, `YARN`s to be cast to `NUMBR`
may lead with `"0"` or `"0x"` to indicate that the string should be
interpreted as an octal or hexadecimal value, respectively.

This change required the modification of several tests which previously
checked that casting an empty or completely non-numeric `YARN` resulted
in an error. These now verify that such a conversion results in a zero
of the appropriate type.
2015-08-30 15:45:53 -07:00
..
1-Addition fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
2-Subtraction fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
3-Multiplication fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
4-Division fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
5-Modulo fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
6-Maximum reordered a couple of tests 2013-03-02 12:55:56 -05:00
7-Minimum fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
8-LogicalANDBinary converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
9-LogicalORBinary converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
10-LogicalXORBinary converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
11-LogicalNOTUnary converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
12-LogicalANDNary converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
13-LogicalORNary converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
14-Equality converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
15-Inequality converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
16-Concatenation fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
17-ExplicitCast relax numeric conversions from string 2015-08-30 15:45:53 -07:00
18-ExplicitRecast relax numeric conversions from string 2015-08-30 15:45:53 -07:00
CMakeLists.txt minor infrastructure stuff 2013-03-02 12:38:49 -05:00