Added leiden oefenopgave test cases.

parent 63ab861b
...@@ -30,6 +30,8 @@ class TestLeidenOefenopgave(TestCase): ...@@ -30,6 +30,8 @@ class TestLeidenOefenopgave(TestCase):
'(xx + x * 1 + 1x + 1 * 1)(x + 1)', '(xx + x * 1 + 1x + 1 * 1)(x + 1)',
'(x ^ (1 + 1) + x * 1 + 1x + 1 * 1)(x + 1)', '(x ^ (1 + 1) + x * 1 + 1x + 1 * 1)(x + 1)',
'(x ^ 2 + x * 1 + 1x + 1 * 1)(x + 1)', '(x ^ 2 + x * 1 + 1x + 1 * 1)(x + 1)',
'(x ^ 2 + x + 1x + 1 * 1)(x + 1)',
'(x ^ 2 + x + x + 1 * 1)(x + 1)',
'(x ^ 2 + (1 + 1)x + 1 * 1)(x + 1)', '(x ^ 2 + (1 + 1)x + 1 * 1)(x + 1)',
'(x ^ 2 + 2x + 1 * 1)(x + 1)', '(x ^ 2 + 2x + 1 * 1)(x + 1)',
'(x ^ 2 + 2x + 1)(x + 1)', '(x ^ 2 + 2x + 1)(x + 1)',
...@@ -40,9 +42,11 @@ class TestLeidenOefenopgave(TestCase): ...@@ -40,9 +42,11 @@ class TestLeidenOefenopgave(TestCase):
'x ^ 3 + x ^ (1 + 1) * 2 + (x ^ 2 + 2x) * 1 + 1x + 1 * 1', 'x ^ 3 + x ^ (1 + 1) * 2 + (x ^ 2 + 2x) * 1 + 1x + 1 * 1',
'x ^ 3 + x ^ 2 * 2 + (x ^ 2 + 2x) * 1 + 1x + 1 * 1', 'x ^ 3 + x ^ 2 * 2 + (x ^ 2 + 2x) * 1 + 1x + 1 * 1',
'x ^ 3 + x ^ 2 * 2 + 1 * x ^ 2 + 1 * 2x + 1x + 1 * 1', 'x ^ 3 + x ^ 2 * 2 + 1 * x ^ 2 + 1 * 2x + 1x + 1 * 1',
'x ^ 3 + x ^ 2 * 2 + x ^ 2 + 1 * 2x + 1x + 1 * 1',
'x ^ 3 + (2 + 1) * x ^ 2 + 1 * 2x + 1x + 1 * 1', 'x ^ 3 + (2 + 1) * x ^ 2 + 1 * 2x + 1x + 1 * 1',
'x ^ 3 + 3 * x ^ 2 + 1 * 2x + 1x + 1 * 1', 'x ^ 3 + 3 * x ^ 2 + 1 * 2x + 1x + 1 * 1',
'x ^ 3 + 3 * x ^ 2 + 2x + 1x + 1 * 1', 'x ^ 3 + 3 * x ^ 2 + 2x + 1x + 1 * 1',
'x ^ 3 + 3 * x ^ 2 + 2x + x + 1 * 1',
'x ^ 3 + 3 * x ^ 2 + (2 + 1)x + 1 * 1', 'x ^ 3 + 3 * x ^ 2 + (2 + 1)x + 1 * 1',
'x ^ 3 + 3 * x ^ 2 + 3x + 1 * 1', 'x ^ 3 + 3 * x ^ 2 + 3x + 1 * 1',
'x ^ 3 + 3 * x ^ 2 + 3x + 1', 'x ^ 3 + 3 * x ^ 2 + 3x + 1',
...@@ -56,6 +60,8 @@ class TestLeidenOefenopgave(TestCase): ...@@ -56,6 +60,8 @@ class TestLeidenOefenopgave(TestCase):
'xx + x * 1 + 1x + 1 * 1', 'xx + x * 1 + 1x + 1 * 1',
'x ^ (1 + 1) + x * 1 + 1x + 1 * 1', 'x ^ (1 + 1) + x * 1 + 1x + 1 * 1',
'x ^ 2 + x * 1 + 1x + 1 * 1', 'x ^ 2 + x * 1 + 1x + 1 * 1',
'x ^ 2 + x + 1x + 1 * 1',
'x ^ 2 + x + x + 1 * 1',
'x ^ 2 + (1 + 1)x + 1 * 1', 'x ^ 2 + (1 + 1)x + 1 * 1',
'x ^ 2 + 2x + 1 * 1', 'x ^ 2 + 2x + 1 * 1',
'x ^ 2 + 2x + 1'], 'x ^ 2 + 2x + 1'],
...@@ -76,15 +82,32 @@ class TestLeidenOefenopgave(TestCase): ...@@ -76,15 +82,32 @@ class TestLeidenOefenopgave(TestCase):
self.assertRewrite(chain) self.assertRewrite(chain)
def test_1_4_1(self): def test_1_4_1(self):
self.assertRewrite(['x * -1 + 1x', '(-1 + 1)x', '0x', '0']) self.assertRewrite(['x * -1 + 1x',
'-x * 1 + 1x',
'-x + 1x',
'-x + x',
'(-1 + 1)x',
'0x',
'0'])
def test_1_4_2(self): def test_1_4_2(self):
# FIXME: self.assertRewrite(['x * -1 - 1x', '(-1 + -1)x', '-2x']) self.assertRewrite(['x * -1 - 1x',
pass '-x * 1 - 1x',
'-x - 1x',
'-x - x',
'(1 + 1) * -x',
'2 * -x',
'-2x'])
def test_1_4_3(self): def test_1_4_3(self):
# FIXME: self.assertRewrite(['x * -1 + x * -1', '(-1 + -1)x', '-2x']) self.assertRewrite(['x * -1 + x * -1',
pass '-x * 1 + x * -1',
'-x + x * -1',
'-x - x * 1',
'-x - x',
'(1 + 1) * -x',
'2 * -x',
'-2x'])
def test_1_5(self): def test_1_5(self):
self.assertRewrite(['(2x + x)x', '(2 + 1)xx', '3xx', self.assertRewrite(['(2x + x)x', '(2 + 1)xx', '3xx',
...@@ -113,18 +136,25 @@ class TestLeidenOefenopgave(TestCase): ...@@ -113,18 +136,25 @@ class TestLeidenOefenopgave(TestCase):
def test_3(self): def test_3(self):
pass pass
def test_4(self): def test_4_1(self):
for exp, solution in [ self.assertRewrite(['2/15 + 1/4', '8 / 60 + 15 / 60', '(8 + 15) / 60',
('2/15 + 1/4', '8 / 60 + 15 / 60'), '23 / 60'])
('8/60 + 15/60', '(8 + 15) / 60'),
('(8 + 15) / 60', '23 / 60'), def test_4_2(self):
('2/7 - 4/11', '22 / 77 - 28 / 77'), self.assertRewrite(['2/7 - 4/11', '22 / 77 - 28 / 77',
('22/77 - 28/77', '(22 - 28) / 77'), '(22 - 28) / 77', '-6 / 77'])
('(22 - 28)/77', '-6 / 77'),
# FIXME: ('(7/3) * (3/5)', '7 / 5'), #def test_4_3(self):
# FIXME: ('(3/4) / (5/6)', '9 / 10'), # self.assertRewrite(['(7/3) * (3/5)', '7 / 5'])
# FIXME: ('1/4 * 1/x', '1 / (4x)'),
# FIXME: ('(3/x^2) / (x/7)', '21 / x^3'), #def test_4_4(self):
# FIXME: ('1/x + 2/(x+1)', '(3x + 1) / (x * (x + 1))'), # self.assertRewrite(['(3/4) / (5/6)', '9 / 10'])
]:
self.assertEqual(str(rewrite(exp)), solution) #def test_4_5(self):
# self.assertRewrite(['1/4 * 1/x', '1 / (4x)'])
#def test_4_6(self):
# self.assertRewrite(['(3/x^2) / (x/7)', '21 / x^3'])
#def test_4_7(self):
# self.assertRewrite(['1/x + 2/(x+1)', '(3x + 1) / (x * (x + 1))'])
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