mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(test): correct _coerce_number inf/nan test assertions
The test 'test_inf_stays_string_for_integer_only' incorrectly asserted
that _coerce_number('inf') returns float('inf'), but the function
correctly returns the original string 'inf' because infinity is not
JSON-serializable.
Fixed the assertion to expect the string 'inf', and added two new tests
for negative infinity and NaN edge cases to improve coverage of the
non-JSON-serializable number guard in _coerce_number().
This commit is contained in:
parent
edf9c75621
commit
652f8e6f3e
1 changed files with 15 additions and 2 deletions
|
|
@ -64,10 +64,23 @@ class TestCoerceNumber:
|
||||||
def test_scientific_notation(self):
|
def test_scientific_notation(self):
|
||||||
assert _coerce_number("1e5") == 100000
|
assert _coerce_number("1e5") == 100000
|
||||||
|
|
||||||
def test_inf_stays_string_for_integer_only(self):
|
def test_inf_stays_string(self):
|
||||||
"""Infinity should not be converted to int."""
|
"""Infinity is not JSON-serializable, so it should stay as string."""
|
||||||
result = _coerce_number("inf")
|
result = _coerce_number("inf")
|
||||||
assert result == "inf"
|
assert result == "inf"
|
||||||
|
assert isinstance(result, str)
|
||||||
|
|
||||||
|
def test_negative_inf_stays_string(self):
|
||||||
|
"""Negative infinity should also stay as string."""
|
||||||
|
result = _coerce_number("-inf")
|
||||||
|
assert result == "-inf"
|
||||||
|
assert isinstance(result, str)
|
||||||
|
|
||||||
|
def test_nan_stays_string(self):
|
||||||
|
"""NaN is not JSON-serializable, so it should stay as string."""
|
||||||
|
result = _coerce_number("nan")
|
||||||
|
assert result == "nan"
|
||||||
|
assert isinstance(result, str)
|
||||||
|
|
||||||
def test_negative_float(self):
|
def test_negative_float(self):
|
||||||
assert _coerce_number("-2.5") == -2.5
|
assert _coerce_number("-2.5") == -2.5
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue