diff options
author | Ajith Ramachandran <ajithar204@gmail.com> | 2021-06-10 16:42:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 16:42:09 (GMT) |
commit | ac867f10b49322e25f34d2d8abd8e63c86834750 (patch) | |
tree | df19019a4f94682e5ed4303fe1328526c831517d /Lib/test/test_math.py | |
parent | 90cd4330329a99e52f7141db5e0a469d30088e66 (diff) | |
download | cpython-ac867f10b49322e25f34d2d8abd8e63c86834750.zip cpython-ac867f10b49322e25f34d2d8abd8e63c86834750.tar.gz cpython-ac867f10b49322e25f34d2d8abd8e63c86834750.tar.bz2 |
bpo-44357:Add `math.cbrt()` function: Cube Root (GH-26622)
* Add math.cbrt() function: Cube Root
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r-- | Lib/test/test_math.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 9eb455a..da16284 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -377,6 +377,22 @@ class MathTests(unittest.TestCase): self.assertTrue(math.isnan(math.atan2(NAN, INF))) self.assertTrue(math.isnan(math.atan2(NAN, NAN))) + def testCbrt(self): + self.assertRaises(TypeError, math.cbrt) + self.ftest('cbrt(0)', math.cbrt(0), 0) + self.ftest('cbrt(1)', math.cbrt(1), 1) + self.ftest('cbrt(8)', math.cbrt(8), 2) + self.ftest('cbrt(0.0)', math.cbrt(0.0), 0.0) + self.ftest('cbrt(-0.0)', math.cbrt(-0.0), -0.0) + self.ftest('cbrt(1.2)', math.cbrt(1.2), 1.062658569182611) + self.ftest('cbrt(-2.6)', math.cbrt(-2.6), -1.375068867074141) + self.ftest('cbrt(27)', math.cbrt(27), 3) + self.ftest('cbrt(-1)', math.cbrt(-1), -1) + self.ftest('cbrt(-27)', math.cbrt(-27), -3) + self.assertEqual(math.cbrt(INF), INF) + self.assertEqual(math.cbrt(NINF), NINF) + self.assertTrue(math.isnan(math.cbrt(NAN))) + def testCeil(self): self.assertRaises(TypeError, math.ceil) self.assertEqual(int, type(math.ceil(0.5))) |