예제 #1
0
파일: test_data.py 프로젝트: washort/typhon
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertTrue(result.bi.int_eq(0x6666))
예제 #2
0
파일: test_data.py 프로젝트: washort/typhon
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertTrue(result.bi.int_eq(0xfffd))
예제 #3
0
 def testApproxDivide(self):
     bi = BigInt(rbigint.fromint(7937000378463977))
     # Hack.
     bj = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
     result = bi.call(u"approxDivide", [bj])
     self.assertAlmostEqual(result._d, 0.0007937000378463977)
예제 #4
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)
예제 #5
0
 def testBitLength(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
예제 #6
0
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertTrue(result.bi.int_eq(-7))
예제 #7
0
파일: nodes.py 프로젝트: zarutian/typhon
 def getValue(self):
     try:
         return IntObject(self.bi.toint())
     except OverflowError:
         return BigInt(self.bi)
예제 #8
0
파일: test_data.py 프로젝트: dckc/typhon
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertEqual(result.getInt(), 0x6666)
예제 #9
0
파일: test_data.py 프로젝트: dckc/typhon
 def testFloorDivideDouble(self):
     bi = BigInt(rbigint.fromint(2).pow(rbigint.fromint(65)))
     result = bi.call(u"floorDivide", [DoubleObject(2.0)])
     self.assertTrue(result.bi.eq(rbigint.fromint(2).pow(rbigint.fromint(64))))
예제 #10
0
파일: nodes.py 프로젝트: zarutian/typhon
 def uncall(self):
     try:
         return wrapList([IntObject(self.bi.toint())])
     except OverflowError:
         return wrapList([BigInt(self.bi)])
예제 #11
0
파일: test_data.py 프로젝트: dckc/typhon
 def testApproxDivideDouble(self):
     bi = BigInt(rbigint.fromint(1))
     result = bi.call(u"approxDivide", [DoubleObject(32.0)])
     self.assertAlmostEqual(result._d, 1.0 / 32.0)
예제 #12
0
파일: test_data.py 프로젝트: dckc/typhon
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertEqual(result.getInt(), -7)
예제 #13
0
파일: test_data.py 프로젝트: dckc/typhon
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertEqual(result.getInt(), 0xfffd)
예제 #14
0
파일: test_data.py 프로젝트: washort/typhon
 def testOpCmpInt(self):
     bi = BigInt(rbigint.fromint(6))
     i = IntObject(2)
     result = bi.call(u"op__cmp", [i])
     self.assertEqual(result.getInt(), 1)
예제 #15
0
파일: mix.py 프로젝트: zarutian/typhon
 def visitIntExpr(self, bi, span):
     try:
         return self.dest.LiveExpr(IntObject(bi.toint()), span)
     except OverflowError:
         return self.dest.LiveExpr(BigInt(bi), span)
예제 #16
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivideNaN(self):
     i = BigInt(rbigint.fromint(0))
     result = i.call(u"approxDivide", [i])
     self.assertTrue(math.isnan(result.getDouble()))
예제 #17
0
 def testBigIntAndIntEquality(self):
     first = BigInt(rbigint.fromint(42))
     second = IntObject(42)
     self.assertEqual(optSame(first, second), EQUAL)
예제 #18
0
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertTrue(result.bi.int_eq(0x6666))
예제 #19
0
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertEqual(result.getInt(), 10)
예제 #20
0
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertTrue(result.bi.int_eq(0xfffd))
예제 #21
0
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertEqual(result.getInt(), 0x6666)
예제 #22
0
 def testOpCmpInt(self):
     bi = BigInt(rbigint.fromint(6))
     i = IntObject(2)
     result = bi.call(u"op__cmp", [i])
     self.assertEqual(result.getInt(), 1)
예제 #23
0
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertEqual(result.getInt(), 0xfffd)
예제 #24
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)
예제 #25
0
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertEqual(result.getInt(), -7)
예제 #26
0
파일: test_data.py 프로젝트: washort/typhon
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertTrue(result.bi.int_eq(10))
예제 #27
0
 def testApproxDivideDouble(self):
     bi = BigInt(rbigint.fromint(1))
     result = bi.call(u"approxDivide", [DoubleObject(32.0)])
     self.assertAlmostEqual(result._d, 1.0 / 32.0)
예제 #28
0
파일: test_data.py 프로젝트: washort/typhon
 def testBitLength(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
예제 #29
0
 def testFloorDivideDouble(self):
     bi = BigInt(rbigint.fromint(2).pow(rbigint.fromint(65)))
     result = bi.call(u"floorDivide", [DoubleObject(2.0)])
     self.assertTrue(
         result.bi.eq(rbigint.fromint(2).pow(rbigint.fromint(64))))
예제 #30
0
파일: test_data.py 프로젝트: washort/typhon
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertTrue(result.bi.int_eq(-7))
예제 #31
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivideNaN(self):
     i = BigInt(rbigint.fromint(0))
     result = i.call(u"approxDivide", [i])
     self.assertTrue(math.isnan(result.getDouble()))
예제 #32
0
파일: test_data.py 프로젝트: washort/typhon
 def testApproxDivide(self):
     bi = BigInt(rbigint.fromint(7937000378463977))
     # Hack.
     bj = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
     result = bi.call(u"approxDivide", [bj])
     self.assertAlmostEqual(result._d, 0.0007937000378463977)
예제 #33
0
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertTrue(result.bi.int_eq(10))
예제 #34
0
파일: test_data.py 프로젝트: washort/typhon
 def testFloorDivideNaN(self):
     i = BigInt(rbigint.fromint(0))
     self.assertRaises(UserException, i.call, u"floorDivide", [i])
예제 #35
0
파일: test_data.py 프로젝트: dckc/typhon
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertEqual(result.getInt(), 10)