[math] Add tests for runtime errors

And fix "isinfinite" - it's called "isinf".
This commit is contained in:
Fabian Homborg 2018-03-07 18:13:26 +01:00
parent 9fc3d1215b
commit 2d08b5ee8a
3 changed files with 7 additions and 1 deletions

View file

@ -150,7 +150,7 @@ static int evaluate_expression(const wchar_t *cmd, parser_t &parser, io_streams_
// TODO: Really, this should be done in tinyexpr
// (e.g. infinite is the result of "x / 0"),
// but that's much more work.
if (std::isinfinite(v)) {
if (std::isinf(v)) {
streams.err.append_format(L"%ls: Error: Result is infinite\n", cmd);
streams.err.append_format(L"'%ls'\n", expression.c_str());
retval = STATUS_CMD_ERROR;

View file

@ -24,3 +24,7 @@ math: Error: Too many arguments
^
math: Expected at least 1 args, got only 0
math: Expected at least 1 args, got only 0
math: Error: Result is too large
'2^650'
math: Error: Result is infinite
'1 / 0'

View file

@ -31,3 +31,5 @@ not math 'sin()'
not math '2 + 2 4'
not math
not math -s 12
not math 2^650
not math 1 / 0