fix: function recursive argument evaluation

This commit is contained in:
2026-02-06 02:21:22 +01:00
parent 8462af9206
commit 3f94e7d88e
2 changed files with 8 additions and 3 deletions

View File

@@ -255,7 +255,7 @@ def _neg(operand):
),
],
)
def test_unary_minus(expression, expected):
def test_unary_minus_parse(expression, expected):
assert parse(expression) == expected
@@ -271,7 +271,12 @@ def test_unary_minus(expression, expected):
("(-2)^2", 0, 4), # (-2)^2 = 4
("pi", 0, math.pi),
("e", 0, math.e),
("abs(-100)", 0, 100),
("abs(pi)", 0, math.pi),
("abs(x)", 0, 0),
("abs(x)", -1.0, 1.0),
("abs(cos(x))", 0, 1.0),
],
)
def test_unary_minus_eval(expression, x, expected):
def test_eval(expression, x, expected):
assert parse(expression).eval(x) == expected