예제 #1
0
파일: test_data.py 프로젝트: washort/typhon
    def testMulDouble(self):
        """
        Ints are promoted by doubles during multiplication.
        """

        i = IntObject(4)
        result = i.call(u"multiply", [DoubleObject(2.1)])
        self.assertTrue(isinstance(result, DoubleObject))
        self.assertEqual(result.getDouble(), 8.4)
예제 #2
0
    def testMulDouble(self):
        """
        Ints are promoted by doubles during multiplication.
        """

        i = IntObject(4)
        result = i.call(u"multiply", [DoubleObject(2.1)])
        self.assertTrue(isinstance(result, DoubleObject))
        self.assertEqual(result.getDouble(), 8.4)
예제 #3
0
파일: test_data.py 프로젝트: washort/typhon
 def testMax(self):
     i = IntObject(3)
     result = i.call(u"max", [IntObject(5)])
     self.assertEqual(result.getInt(), 5)
예제 #4
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivideNaN(self):
     i = IntObject(0)
     result = i.call(u"approxDivide", [i])
     self.assertTrue(math.isnan(result.getDouble()))
예제 #5
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivide(self):
     i = IntObject(4)
     result = i.call(u"approxDivide", [IntObject(2)])
     self.assertAlmostEqual(result.getDouble(), 2.0)
예제 #6
0
 def testAdd(self):
     i = IntObject(32)
     result = i.call(u"add", [IntObject(11)])
     self.assertEqual(result.getInt(), 43)
예제 #7
0
파일: test_data.py 프로젝트: washort/typhon
 def testShiftRightLarge(self):
     i = IntObject(0x7fffffffffffffff)
     result = i.call(u"shiftRight", [IntObject(64)])
     self.assertEqual(result.getInt(), 0x0)
예제 #8
0
파일: test_data.py 프로젝트: washort/typhon
 def testModPow(self):
     i = IntObject(3)
     result = i.call(u"modPow", [IntObject(1000000), IntObject(255)])
     self.assertEqual(result.getInt(), 171)
예제 #9
0
 def testMin(self):
     i = IntObject(3)
     result = i.call(u"min", [IntObject(5)])
     self.assertEqual(result.getInt(), 3)
예제 #10
0
 def testComplement(self):
     i = IntObject(5)
     result = i.call(u"complement", [])
     self.assertEqual(result.getInt(), -6)
예제 #11
0
 def testMax(self):
     i = IntObject(3)
     result = i.call(u"max", [IntObject(5)])
     self.assertEqual(result.getInt(), 5)
예제 #12
0
 def testApproxDivideBigInt(self):
     i = IntObject(7937000378463977)
     # Hack.
     bi = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
     result = i.call(u"approxDivide", [bi])
     self.assertAlmostEqual(result._d, 0.0007937000378463977)
예제 #13
0
 def testApproxDivide(self):
     i = IntObject(4)
     result = i.call(u"approxDivide", [IntObject(2)])
     self.assertAlmostEqual(result.getDouble(), 2.0)
예제 #14
0
 def testAddDouble(self):
     i = IntObject(32)
     result = i.call(u"add", [DoubleObject(1.1)])
     self.assertAlmostEqual(result.getDouble(), 33.1)
예제 #15
0
파일: test_data.py 프로젝트: washort/typhon
 def testOpCmpBigInt(self):
     i = IntObject(2)
     bi = BigInt(rbigint.fromint(6))
     result = i.call(u"op__cmp", [bi])
     self.assertEqual(result.getInt(), -1)
예제 #16
0
 def testOpCmpDouble(self):
     i = IntObject(2)
     result = i.call(u"op__cmp", [DoubleObject(2.0)])
     self.assertEqual(result.getInt(), 0)
예제 #17
0
파일: test_data.py 프로젝트: washort/typhon
 def testPowSmall(self):
     i = IntObject(5)
     result = i.call(u"pow", [IntObject(7)])
     self.assertEqual(result.getInt(), 78125)
예제 #18
0
 def testOpCmpBigInt(self):
     i = IntObject(2)
     bi = BigInt(rbigint.fromint(6))
     result = i.call(u"op__cmp", [bi])
     self.assertEqual(result.getInt(), -1)
예제 #19
0
파일: test_data.py 프로젝트: washort/typhon
 def testShiftLeftFar(self):
     i = IntObject(0x1)
     result = i.call(u"shiftLeft", [IntObject(65)])
     bi = rbigint.fromint(0x1).lshift(65)
     self.assertTrue(result.bi.eq(bi))
예제 #20
0
 def testOr(self):
     i = IntObject(0x3)
     result = i.call(u"or", [IntObject(0x5)])
     self.assertEqual(result.getInt(), 0x7)
예제 #21
0
파일: test_data.py 프로젝트: washort/typhon
 def testSubtractDouble(self):
     i = IntObject(5)
     result = i.call(u"subtract", [DoubleObject(1.5)])
     self.assertAlmostEqual(result.getDouble(), 3.5)
예제 #22
0
 def testPowSmall(self):
     i = IntObject(5)
     result = i.call(u"pow", [IntObject(7)])
     self.assertEqual(result.getInt(), 78125)
예제 #23
0
파일: test_data.py 프로젝트: washort/typhon
 def testAddDouble(self):
     i = IntObject(32)
     result = i.call(u"add", [DoubleObject(1.1)])
     self.assertAlmostEqual(result.getDouble(), 33.1)
예제 #24
0
 def testPow(self):
     i = IntObject(3)
     result = i.call(u"pow", [IntObject(100)])
     self.assertTrue(result.bi.eq(rbigint.fromint(3).pow(rbigint.fromint(100))))
예제 #25
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivideBigInt(self):
     i = IntObject(7937000378463977)
     # Hack.
     bi = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
     result = i.call(u"approxDivide", [bi])
     self.assertAlmostEqual(result._d, 0.0007937000378463977)
예제 #26
0
 def testModPow(self):
     i = IntObject(3)
     result = i.call(u"modPow", [IntObject(1000000), IntObject(255)])
     self.assertEqual(result.getInt(), 171)
예제 #27
0
파일: test_data.py 프로젝트: washort/typhon
 def testComplement(self):
     i = IntObject(5)
     result = i.call(u"complement", [])
     self.assertEqual(result.getInt(), -6)
예제 #28
0
 def testShiftLeftLarge(self):
     i = IntObject(0x5c5c)
     result = i.call(u"shiftLeft", [IntObject(64)])
     bi = rbigint.fromint(0x5c5c).lshift(64)
     self.assertTrue(result.bi.eq(bi))
예제 #29
0
파일: test_data.py 프로젝트: washort/typhon
 def testMin(self):
     i = IntObject(3)
     result = i.call(u"min", [IntObject(5)])
     self.assertEqual(result.getInt(), 3)
예제 #30
0
 def testShiftLeftFar(self):
     i = IntObject(0x1)
     result = i.call(u"shiftLeft", [IntObject(65)])
     bi = rbigint.fromint(0x1).lshift(65)
     self.assertTrue(result.bi.eq(bi))
예제 #31
0
파일: test_data.py 프로젝트: washort/typhon
 def testOpCmpDouble(self):
     i = IntObject(2)
     result = i.call(u"op__cmp", [DoubleObject(2.0)])
     self.assertEqual(result.getInt(), 0)
예제 #32
0
 def testShiftRight(self):
     i = IntObject(0xf0)
     result = i.call(u"shiftRight", [IntObject(5)])
     self.assertEqual(result.getInt(), 0x7)
예제 #33
0
파일: test_data.py 프로젝트: washort/typhon
 def testOr(self):
     i = IntObject(0x3)
     result = i.call(u"or", [IntObject(0x5)])
     self.assertEqual(result.getInt(), 0x7)
예제 #34
0
 def testShiftRightLarge(self):
     i = IntObject(0x7fffffffffffffff)
     result = i.call(u"shiftRight", [IntObject(64)])
     self.assertEqual(result.getInt(), 0x0)
예제 #35
0
파일: test_data.py 프로젝트: washort/typhon
 def testPow(self):
     i = IntObject(3)
     result = i.call(u"pow", [IntObject(100)])
     self.assertTrue(
         result.bi.eq(rbigint.fromint(3).pow(rbigint.fromint(100))))
예제 #36
0
 def testSubtract(self):
     i = IntObject(5)
     result = i.call(u"subtract", [IntObject(15)])
     self.assertAlmostEqual(result.getInt(), -10)
예제 #37
0
파일: test_data.py 프로젝트: washort/typhon
 def testShiftLeftLarge(self):
     i = IntObject(0x5c5c)
     result = i.call(u"shiftLeft", [IntObject(64)])
     bi = rbigint.fromint(0x5c5c).lshift(64)
     self.assertTrue(result.bi.eq(bi))
예제 #38
0
 def testSubtractDouble(self):
     i = IntObject(5)
     result = i.call(u"subtract", [DoubleObject(1.5)])
     self.assertAlmostEqual(result.getDouble(), 3.5)
예제 #39
0
파일: test_data.py 프로젝트: washort/typhon
 def testShiftRight(self):
     i = IntObject(0xf0)
     result = i.call(u"shiftRight", [IntObject(5)])
     self.assertEqual(result.getInt(), 0x7)
예제 #40
0
 def testBitLength(self):
     i = IntObject(42)
     result = i.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
예제 #41
0
파일: test_data.py 프로젝트: washort/typhon
 def testSubtract(self):
     i = IntObject(5)
     result = i.call(u"subtract", [IntObject(15)])
     self.assertAlmostEqual(result.getInt(), -10)
예제 #42
0
파일: test_data.py 프로젝트: washort/typhon
 def testAdd(self):
     i = IntObject(32)
     result = i.call(u"add", [IntObject(11)])
     self.assertEqual(result.getInt(), 43)
예제 #43
0
파일: test_data.py 프로젝트: washort/typhon
 def testBitLength(self):
     i = IntObject(42)
     result = i.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
예제 #44
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivideNaN(self):
     i = IntObject(0)
     result = i.call(u"approxDivide", [i])
     self.assertTrue(math.isnan(result.getDouble()))