This website requires JavaScript.
Explore
Drone CI
Help
Register
Sign In
lcpp
/
lci
Watch
1
Star
0
Fork
You've already forked lci
0
Code
Issues
Pull Requests
Releases
Wiki
Activity
f5f5edb889
lci
/
test
/
1.3-Tests
/
7-Operators
/
17-ExplicitCast
/
4-ToFloat
/
5-FromString
/
3-NonNumber
/
CMakeLists.txt
3 lines
62 B
CMake
Raw
Normal View
History
Unescape
Escape
converted build toolchain to CMake
2012-01-01 04:53:54 +00:00
INCLUDE
(
AddLolTest
)
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-15 23:43:05 +00:00
ADD_LOL_TEST
(
3-NonNumber
OUTPUT
test.out
)