import pytest import tool_functions def test_math_evaluate_1(): result = tool_functions.math_evaluate("1+2*pi") assert result == "1 + 2*pi = 7.28318530717959" def test_math_evaluate_2a(): result = tool_functions.math_evaluate("2**4") assert result == "2**4 = 16" def test_math_evaluate_2b(): """ test that ^ notation is also working, original sympy cannot do this """ result = tool_functions.math_evaluate("2^4") assert result == "2**4 = 16" def test_math_evaluate_3(): result = tool_functions.math_evaluate("Integral(exp(-x**2), (x, -oo, oo))") assert result == "Integral(exp(-x**2), (x, -oo, oo)) = sqrt(pi) = 1.77245385090552" def test_math_evaluate_4(): result = tool_functions.math_evaluate("(2**x)**2") assert result == "(2**x)**2 = 2**(2*x) = 2.0**(2*x)" def test_math_evaluate_5(): result = tool_functions.math_evaluate("sin(pi/2) + cos(0)") assert result == "sin(pi/2) + cos(0) = 2" def test_math_solver_1(): result = tool_functions.math_evaluate("solve x = 1 for x") assert result == "solved x = 1 for x = {1}" def test_math_solver_2(): result = tool_functions.math_evaluate("solve (x + 1)*(x - 1) = 1 for x") assert result == "solved (x + 1)*(x - 1*1) = 1 for x = {-sqrt(2), sqrt(2)}" def test_math_solver_3a(): result = tool_functions.math_evaluate("solve 2*x + 3*y = 7 and x - y = 1 for x, y") assert result == "Solved equation system 2*x + 3*y = 7 and x - y = 1 for x=2 and y=1." def test_math_solver_3b(): result = tool_functions.math_evaluate("solve 2*x + 3*y = 7, x - y = 1 for x and y") assert result == "Solved equation system 2*x + 3*y = 7 and x - y = 1 for x=2 and y=1." def test_math_solver_4(): result = tool_functions.math_evaluate("solve 2*x**3 + 3*y = 7 and x - y = 1 for x, y") assert result == "Solved equation system 2*x**3 + 3*y = 7 and x - y = 1 for x=~1.421 and y=~0.421."