From 85b75c4abbdeb8c4ec57c7d38d8f389359d6301d Mon Sep 17 00:00:00 2001 From: fdai7763 Date: Tue, 23 Jan 2024 22:40:40 +0100 Subject: [PATCH] added test for identify if function is constant and simplify it as well as corresponding functionality --- src/main/py/read_math_function.py | 4 ++-- src/test/py/test_read_math_function.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/py/read_math_function.py b/src/main/py/read_math_function.py index 5e08a78..bb0fee6 100644 --- a/src/main/py/read_math_function.py +++ b/src/main/py/read_math_function.py @@ -49,5 +49,5 @@ def calculate_constant_string(string): def simplify_easy_math_function(type, function): if type != "v": return False - if is_string(function) == False: - return function + if is_string(function) == False or is_allowed_string("c", function) == True: + return simplify_constant("c", function) \ No newline at end of file diff --git a/src/test/py/test_read_math_function.py b/src/test/py/test_read_math_function.py index 4d08b4f..70cb55f 100644 --- a/src/test/py/test_read_math_function.py +++ b/src/test/py/test_read_math_function.py @@ -36,6 +36,8 @@ class read_function(unittest.TestCase): self.assertEqual(simplify_easy_math_function("a", "42x"), False) def test_easy_function_number_as_function_return(self): self.assertEqual(simplify_easy_math_function("v", 42), 42) + def test_easy_function_string_is_constant(self): + self.assertEqual(simplify_easy_math_function("v", "42^(2)+1-3*4/3"), 1761) if __name__ == '__main__': unittest.main()