MCPcopy Index your code
hub / github.com/python/cpython / testLog2

Method testLog2

Lib/test/test_math.py:1247–1274  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1245
1246 @requires_IEEE_754
1247 def testLog2(self):
1248 self.assertRaises(TypeError, math.log2)
1249
1250 # Check some integer values
1251 self.assertEqual(math.log2(1), 0.0)
1252 self.assertEqual(math.log2(2), 1.0)
1253 self.assertEqual(math.log2(4), 2.0)
1254 self.assertEqual(math.log2(MyIndexable(4)), 2.0)
1255
1256 # Large integer values
1257 self.assertEqual(math.log2(2**1023), 1023.0)
1258 self.assertEqual(math.log2(2**1024), 1024.0)
1259 self.assertEqual(math.log2(2**2000), 2000.0)
1260 self.assertEqual(math.log2(MyIndexable(2**2000)), 2000.0)
1261
1262 self.assertRaises(ValueError, math.log2, 0.0)
1263 self.assertRaises(ValueError, math.log2, 0)
1264 self.assertRaises(ValueError, math.log2, MyIndexable(0))
1265 self.assertRaises(ValueError, math.log2, -1.5)
1266 self.assertRaises(ValueError, math.log2, -1)
1267 self.assertRaises(ValueError, math.log2, MyIndexable(-1))
1268 self.assertRaises(ValueError, math.log2, -2**2000)
1269 self.assertRaises(ValueError, math.log2, MyIndexable(-2**2000))
1270 self.assertRaises(ValueError, math.log2, NINF)
1271 self.assertTrue(math.isnan(math.log2(NAN)))
1272
1273 self.assertEqual(math.log2(IndexableFloatLike(8.0, 2**2000)), 3.0)
1274 self.assertEqual(math.log2(IndexableFloatLike(OverflowError(), 2**2000)), 2000.0)
1275
1276 @requires_IEEE_754
1277 # log2() is not accurate enough on Mac OS X Tiger (10.4)

Callers

nothing calls this directly

Calls 5

IndexableFloatLikeClass · 0.85
assertTrueMethod · 0.80
MyIndexableClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected