mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
[math] Add tests for runtime errors
And fix "isinfinite" - it's called "isinf".
This commit is contained in:
parent
9fc3d1215b
commit
2d08b5ee8a
3 changed files with 7 additions and 1 deletions
|
@ -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
|
// TODO: Really, this should be done in tinyexpr
|
||||||
// (e.g. infinite is the result of "x / 0"),
|
// (e.g. infinite is the result of "x / 0"),
|
||||||
// but that's much more work.
|
// 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: Error: Result is infinite\n", cmd);
|
||||||
streams.err.append_format(L"'%ls'\n", expression.c_str());
|
streams.err.append_format(L"'%ls'\n", expression.c_str());
|
||||||
retval = STATUS_CMD_ERROR;
|
retval = STATUS_CMD_ERROR;
|
||||||
|
|
|
@ -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: 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'
|
||||||
|
|
|
@ -31,3 +31,5 @@ not math 'sin()'
|
||||||
not math '2 + 2 4'
|
not math '2 + 2 4'
|
||||||
not math
|
not math
|
||||||
not math -s 12
|
not math -s 12
|
||||||
|
not math 2^650
|
||||||
|
not math 1 / 0
|
||||||
|
|
Loading…
Reference in a new issue