diff options
Diffstat (limited to 'tests/run/powop.pyx')
-rw-r--r-- | tests/run/powop.pyx | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/tests/run/powop.pyx b/tests/run/powop.pyx index 414774562..356425a85 100644 --- a/tests/run/powop.pyx +++ b/tests/run/powop.pyx @@ -1,3 +1,5 @@ +cimport cython + def f(obj2, obj3): """ >>> f(1.0, 2.95)[0] == f(1.0, 2.95)[1] @@ -55,14 +57,27 @@ def small_int_pow(long s): return s**0, s**1, s**2, s**3, s**4 +@cython.cpow(True) +def int_pow_cpow(short a, short b): + """ + >>> int_pow_cpow(7, 2) + 49 + >>> int_pow_cpow(5, 3) + 125 + >>> int_pow_cpow(2, 10) + 1024 + """ + return a**b + +@cython.cpow(False) def int_pow(short a, short b): """ >>> int_pow(7, 2) - 49 + 49.0 >>> int_pow(5, 3) - 125 + 125.0 >>> int_pow(2, 10) - 1024 + 1024.0 """ return a**b @@ -123,9 +138,9 @@ def optimised_pow2(n): 0.5 >>> optimised_pow2(0.5) == 2 ** 0.5 True - >>> optimised_pow2('test') + >>> optimised_pow2('test') # doctest: +ELLIPSIS Traceback (most recent call last): - TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'str' + TypeError: ...operand... **... """ if isinstance(n, (int, long)) and 0 <= n < 1000: assert isinstance(2.0 ** n, float), 'float %s' % n @@ -153,9 +168,9 @@ def optimised_pow2_inplace(n): 0.5 >>> optimised_pow2_inplace(0.5) == 2 ** 0.5 True - >>> optimised_pow2_inplace('test') #doctest: +ELLIPSIS + >>> optimised_pow2_inplace('test') # doctest: +ELLIPSIS Traceback (most recent call last): - TypeError: unsupported operand type(s) for ...: 'int' and 'str' + TypeError: ...operand... **... """ x = 2 x **= n |