From 26e5341c003066cae00c01e76384b47739cd6f7d Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sat, 29 Dec 2001 00:16:09 +0000 Subject: [PATCH] SF Patch #494876, test invalid parameters to pow() --- Lib/test/test_b2.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Lib/test/test_b2.py b/Lib/test/test_b2.py index ca26a771840..c5af1b31f5a 100644 --- a/Lib/test/test_b2.py +++ b/Lib/test/test_b2.py @@ -105,6 +105,26 @@ if fcmp(pow(x, y, z), 24.0): raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z) +try: pow(-1, -2, 3) +except TypeError: pass +else: raise TestFailed, 'pow(1, -2, 3) should raise TypeError' + +try: pow(1, 2, 0) +except ValueError: pass +else: raise TestFailed, 'pow(1, 2, 0) should raise ValueError' + +try: pow(-1L, -2L, 3L) +except TypeError: pass +else: raise TestFailed, 'pow(1L, -2L, 3L) should raise TypeError' + +try: pow(1L, 2L, 0L) +except ValueError: pass +else: raise TestFailed, 'pow(1L, 2L, 0L) should raise ValueError' + +try: pow(-342.43, 0.234) +except ValueError: pass +else: raise TestFailed, 'pow(-342.43, 0.234) should raise ValueError' + print 'range' if range(3) != [0, 1, 2]: raise TestFailed, 'range(3)' if range(1, 5) != [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)'