diff --git a/lms/lib/symmath/symmath_check.py b/lms/lib/symmath/symmath_check.py index dc6fe60398..0a4ff84f70 100644 --- a/lms/lib/symmath/symmath_check.py +++ b/lms/lib/symmath/symmath_check.py @@ -325,53 +325,3 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None msg += '
' return {'ok': False, 'msg': msg, 'ex': fexpect, 'got': fsym} - -#----------------------------------------------------------------------------- -# tests - - -def sctest1(): - x = "1/2*(1+(k_e* Q* q)/(m *g *h^2))" - y = ''' - - - - 1 - 2 - - - ( - 1 - + - - - - k - e - - - Q - - q - - - m - - - g - - - - h - 2 - - - - ) - - - -'''.strip() - z = "1/2(1+(k_e* Q* q)/(m *g *h^2))" - r = sympy_check2(x, z, {'a': z, 'a_fromjs': y}, 'a') - return r diff --git a/lms/lib/symmath/test_symmath_check.py b/lms/lib/symmath/test_symmath_check.py index 71b8f45aad..2d015fcb53 100644 --- a/lms/lib/symmath/test_symmath_check.py +++ b/lms/lib/symmath/test_symmath_check.py @@ -10,6 +10,64 @@ class SymmathCheckTest(TestCase): number_list = [i + 0.01 for i in range(-100, 100)] self._symmath_check_numbers(number_list) + def test_symmath_check_same_symbols(self): + expected_str = "x+2*y" + dynamath = ''' + + + + x + + + 2 + * + y + + +'''.strip() + + # Expect that the exact same symbolic string is marked correct + result = symmath_check(expected_str, expected_str, dynamath=[dynamath]) + self.assertTrue('ok' in result and result['ok']) + + def test_symmath_check_equivalent_symbols(self): + expected_str = "x+2*y" + input_str = "x+y+y" + dynamath = ''' + + + + x + + + y + + + y + + +'''.strip() + + # Expect that equivalent symbolic strings are marked correct + result = symmath_check(expected_str, input_str, dynamath=[dynamath]) + self.assertTrue('ok' in result and result['ok']) + + def test_symmath_check_different_symbols(self): + expected_str = "0" + input_str = "x+y" + dynamath = ''' + + + + x + + + y + + +'''.strip() + + # Expect that an incorrect response is marked incorrect + result = symmath_check(expected_str, input_str, dynamath=[dynamath]) + self.assertTrue('ok' in result and not result['ok']) + self.assertFalse('fail' in result['msg']) + def _symmath_check_numbers(self, number_list): for n in number_list: