From 6e54e1e623ee37db980a89abc47aeea33b9b4dd6 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 14 Mar 2009 22:13:11 -0700 Subject: [PATCH] int powering tests --- tests/errors/e_powop.pyx | 5 ----- tests/run/powop.pyx | 26 ++++++++++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/errors/e_powop.pyx b/tests/errors/e_powop.pyx index 7dac877b..a73e6937 100644 --- a/tests/errors/e_powop.pyx +++ b/tests/errors/e_powop.pyx @@ -1,15 +1,10 @@ def f(): cdef char *str1 cdef float flt1, flt2, flt3 - cdef int int1 = 1, int2 = 2, int3 flt1 = str1 ** flt3 # error flt1 = flt2 ** str1 # error - int3 = int1 ** int2 # disabled in Cython - int3 = 3 ** 4 # disabled in Cython _ERRORS = u""" 5:13: Invalid operand types for '**' (char *; float) 6:13: Invalid operand types for '**' (float; char *) -7:13: C has no integer powering, use python ints or floats instead '**' (int; int) -8:10: C has no integer powering, use python ints or floats instead '**' (long; long) """ diff --git a/tests/run/powop.pyx b/tests/run/powop.pyx index 3d8c9b0f..cbc291dd 100644 --- a/tests/run/powop.pyx +++ b/tests/run/powop.pyx @@ -8,17 +8,25 @@ __doc__ = u""" >>> h(4) 625 - >>> constant_py() == 2L ** 10 + >>> constant_py() == 2 ** 10 True - >>> constant_long() == 2L ** 36 + >>> constant_long() == 2 ** 36 True + + >>> small_int_pow(3) + (1, 3, 9, 27, 81) + >>> small_int_pow(-5) + (1, -5, 25, -125, 625) + + >>> int_pow(7, 2) + 49 + >>> int_pow(5, 3) + 125 + >>> int_pow(2, 10) + 1024 """ -import sys -if sys.version_info[0] >= 3: - __doc__ = __doc__.replace(u"2L", u"2") - def f(obj2, obj3): cdef float flt1, flt2, flt3 flt2, flt3 = obj2, obj3 @@ -40,3 +48,9 @@ def constant_py(): def constant_long(): result = (2L) ** 36 return result + +def small_int_pow(long s): + return s**0, s**1, s**2, s**3, s**4 + +def int_pow(short a, short b): + return a**b -- 2.26.2