]> granicus.if.org Git - python/commitdiff
SF Patch #494876, test invalid parameters to pow()
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 29 Dec 2001 00:16:09 +0000 (00:16 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 29 Dec 2001 00:16:09 +0000 (00:16 +0000)
Lib/test/test_b2.py

index ca26a7718408c4df68b6b2368f16a93888af1503..c5af1b31f5a2372af80ecd8608a544f0242d5909 100644 (file)
@@ -105,6 +105,26 @@ for x in 2, 2L, 2.0:
                 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)'