Commit 8f84aef4 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added a unit test that mysteriously failes validation...

parent 1f798cfb
......@@ -32,21 +32,27 @@ def validate(exp, result):
parser.set_root_node(exp)
a = parser.rewrite_all()
if not a:
return False
parser.set_root_node(result)
b = parser.rewrite_all()
if not a or not a.equals(b):
if not a.equals(b):
return False
# TODO: make sure cycles are avoided / eliminated using cycle detection.
def traverse_preorder(node, result):
#print 'node:', node, 'result:', result
if node.equals(result):
return True
for p in find_possibilities(node):
# Clone the root node because it will be used in multiple
# substitutions
child = apply_suggestion(node.clone(), p)
temp = node.clone()
child = apply_suggestion(node, p)
node = temp
if traverse_preorder(child, result):
return True
......
......@@ -31,6 +31,10 @@ class TestValidation(TestCase):
def test_intermediate_failure(self):
self.assertFalse(validate('3a + a + b + 2b', '4a + 4b'))
#def test_success(self):
# self.assertTrue(validate('x^2 + x - 2x^2 + 3x + 1',
# 'x^2 + 4x - 2x^2 + 1'))
#def test_indefinite_integral(self):
# self.assertTrue(validate('int_2^4 x^2', '4^3/3 - 2^3/3'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment