Browse Source

added test for easy linear function where the constant gets simplified as well as corresponding functionality

remotes/origin/feature/feature-read-math-functions
fdai7763 11 months ago
parent
commit
2e95448ace
  1. 5
      src/main/py/read_math_function.py
  2. 2
      src/test/py/test_read_math_function.py

5
src/main/py/read_math_function.py

@ -52,6 +52,11 @@ def simplify_easy_math_function(type, function):
return False
if is_string(function) is False or is_allowed_string("c", function) is True:
return simplify_constant("c", function)
extracted_function = extract_constant(function)
simplified_constant = simplify_constant("c", extracted_function[0])
extracted_function[0] = simplified_constant
return extracted_function
def extract_constant(function):

2
src/test/py/test_read_math_function.py

@ -46,6 +46,8 @@ class read_function(unittest.TestCase):
self.assertEqual(extract_constant("42x"), ["0", "42x"])
def test_extraction_linear_function_constant_with_math_operators(self):
self.assertEqual(extract_constant("42x+42^(2)+1-3*4/3"), ["42^(2)+1-3*4/3", "42x"])
def test_easy_function_linear_constant_gets_simplified(self):
self.assertEqual(simplify_easy_math_function("v", "42x+42^(2)+1-3*4/3"), [1761, "42x"])
if __name__ == '__main__':
unittest.main()
Loading…
Cancel
Save