summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorGideon <41593269+Turreted@users.noreply.github.com>2021-11-29 18:55:43 (GMT)
committerGitHub <noreply@github.com>2021-11-29 18:55:43 (GMT)
commit6266e4af873a27c9d352115f2f7a1ad0885fc031 (patch)
treef7cccb86aa38df82d29cf17767c8c7f571e5cf00 /Lib/test/test_math.py
parentc1f93f0d378958dfae4f24aad0c0088e3e04e403 (diff)
downloadcpython-6266e4af873a27c9d352115f2f7a1ad0885fc031.zip
cpython-6266e4af873a27c9d352115f2f7a1ad0885fc031.tar.gz
cpython-6266e4af873a27c9d352115f2f7a1ad0885fc031.tar.bz2
bpo-45917: Add math.exp2() method - return 2 raised to the power of x (GH-29829)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index a9f1b1e..a7df00f 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -501,6 +501,17 @@ class MathTests(unittest.TestCase):
self.assertTrue(math.isnan(math.exp(NAN)))
self.assertRaises(OverflowError, math.exp, 1000000)
+ def testExp2(self):
+ self.assertRaises(TypeError, math.exp2)
+ self.ftest('exp2(-1)', math.exp2(-1), 0.5)
+ self.ftest('exp2(0)', math.exp2(0), 1)
+ self.ftest('exp2(1)', math.exp2(1), 2)
+ self.ftest('exp2(2.3)', math.exp2(2.3), 4.924577653379665)
+ self.assertEqual(math.exp2(INF), INF)
+ self.assertEqual(math.exp2(NINF), 0.)
+ self.assertTrue(math.isnan(math.exp2(NAN)))
+ self.assertRaises(OverflowError, math.exp2, 1000000)
+
def testFabs(self):
self.assertRaises(TypeError, math.fabs)
self.ftest('fabs(-1)', math.fabs(-1), 1)