debug fraction hope it's last bug...

This commit is contained in:
lafrite 2014-11-14 17:00:26 +01:00
parent c30fd89282
commit 057cbaeab7
2 changed files with 15 additions and 2 deletions

View File

@ -169,7 +169,8 @@ class Fraction(object):
return number - self
def __neg__(self):
return Fraction(-self._num,self._denom).simplify()
f = Fraction(-self._num, self._denom)
return [f] + f.simplify()
def __mul__(self, other):
steps = []

View File

@ -61,7 +61,19 @@ class TestFraction(unittest.TestCase):
self.assertEqual(res, ans[i][j])
def test_neg(self):
pass
ans = [ Fraction(-1,3), \
Fraction(-2,3), \
Fraction(-4,5), \
Fraction(1, 3), \
Fraction(1,3), \
-1
]
for (j, f) in enumerate(self.listAgainst):
res = -f
if type(res) == list:
self.assertEqual(res[-1], ans[j])
else:
self.assertEqual(res, ans[j])
def test_mul(self):
ans = [[Fraction(1, 9), Fraction(2,9), Fraction(4, 15), Fraction(-1,9), Fraction(-1,9), Fraction(1,3)], \