コード例 #1
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testBitLength(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testBitLength(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
コード例 #5
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))
コード例 #6
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testOpCmpInt(self):
     bi = BigInt(rbigint.fromint(6))
     i = IntObject(2)
     result = bi.call(u"op__cmp", [i])
     self.assertEqual(result.getInt(), 1)
コード例 #7
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))
コード例 #8
0
ファイル: test_data.py プロジェクト: zarutian/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 プロジェクト: zarutian/typhon
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertEqual(result.getInt(), 0xfffd)
コード例 #10
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))))
コード例 #11
0
ファイル: test_data.py プロジェクト: zarutian/typhon
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertEqual(result.getInt(), 10)
コード例 #12
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)
コード例 #13
0
ファイル: test_data.py プロジェクト: dckc/typhon
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertEqual(result.getInt(), -7)
コード例 #14
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)
コード例 #15
0
ファイル: test_data.py プロジェクト: markrwilliams/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))
コード例 #16
0
ファイル: test_data.py プロジェクト: zarutian/typhon
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertEqual(result.getInt(), -7)
コード例 #17
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertTrue(result.bi.int_eq(-7))
コード例 #18
0
ファイル: test_data.py プロジェクト: zarutian/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)
コード例 #19
0
ファイル: test_data.py プロジェクト: markrwilliams/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)
コード例 #20
0
ファイル: test_data.py プロジェクト: zarutian/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))))
コード例 #21
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))
コード例 #22
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()))
コード例 #23
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))
コード例 #24
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertTrue(result.bi.int_eq(10))
コード例 #25
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)
コード例 #26
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertTrue(result.bi.int_eq(0x6666))
コード例 #27
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()))
コード例 #28
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)