def testArithmetic(self):
    self.assertEqual(F(1, 2), (F(1, 10) + F(2, 5)))
    self.assertEqual(F((- 3), 10), (F(1, 10) - F(2, 5)))
    self.assertEqual(F(1, 25), (F(1, 10) * F(2, 5)))
    self.assertEqual(F(1, 4), (F(1, 10) / F(2, 5)))
    self.assertTypedEquals(2, (F(9, 10) // F(2, 5)))
    self.assertTypedEquals((10 ** 23), (F((10 ** 23), 1) // F(1)))
    self.assertEqual(F(2, 3), (F((- 7), 3) % F(3, 2)))
    self.assertEqual(F(8, 27), (F(2, 3) ** F(3)))
    self.assertEqual(F(27, 8), (F(2, 3) ** F((- 3))))
    self.assertTypedEquals(2.0, (F(4) ** F(1, 2)))
    self.assertEqual(F(1, 1), (+ F(1, 1)))
    z = pow(F((- 1)), F(1, 2))
    self.assertAlmostEqual(z.real, 0)
    self.assertEqual(z.imag, 1)
    p = (F((- 1), 2) ** 0)
    self.assertEqual(p, F(1, 1))
    self.assertEqual(p.numerator, 1)
    self.assertEqual(p.denominator, 1)
    p = (F((- 1), 2) ** (- 1))
    self.assertEqual(p, F((- 2), 1))
    self.assertEqual(p.numerator, (- 2))
    self.assertEqual(p.denominator, 1)
    p = (F((- 1), 2) ** (- 2))
    self.assertEqual(p, F(4, 1))
    self.assertEqual(p.numerator, 4)
    self.assertEqual(p.denominator, 1)
def testArithmetic(self):
    self.assertEqual(F(1, 2), (F(1, 10) + F(2, 5)))
    self.assertEqual(F((- 3), 10), (F(1, 10) - F(2, 5)))
    self.assertEqual(F(1, 25), (F(1, 10) * F(2, 5)))
    self.assertEqual(F(1, 4), (F(1, 10) / F(2, 5)))
    self.assertTypedEquals(2, (F(9, 10) // F(2, 5)))
    self.assertTypedEquals((10 ** 23), (F((10 ** 23), 1) // F(1)))
    self.assertEqual(F(2, 3), (F((- 7), 3) % F(3, 2)))
    self.assertEqual(F(8, 27), (F(2, 3) ** F(3)))
    self.assertEqual(F(27, 8), (F(2, 3) ** F((- 3))))
    self.assertTypedEquals(2.0, (F(4) ** F(1, 2)))
    self.assertEqual(F(1, 1), (+ F(1, 1)))
    z = pow(F((- 1)), F(1, 2))
    self.assertAlmostEqual(z.real, 0)
    self.assertEqual(z.imag, 1)
    p = (F((- 1), 2) ** 0)
    self.assertEqual(p, F(1, 1))
    self.assertEqual(p.numerator, 1)
    self.assertEqual(p.denominator, 1)
    p = (F((- 1), 2) ** (- 1))
    self.assertEqual(p, F((- 2), 1))
    self.assertEqual(p.numerator, (- 2))
    self.assertEqual(p.denominator, 1)
    p = (F((- 1), 2) ** (- 2))
    self.assertEqual(p, F(4, 1))
    self.assertEqual(p.numerator, 4)
    self.assertEqual(p.denominator, 1)