Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
6e54e1e6
Commit
6e54e1e6
authored
Mar 14, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
int powering tests
parent
64724e68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
tests/errors/e_powop.pyx
tests/errors/e_powop.pyx
+0
-5
tests/run/powop.pyx
tests/run/powop.pyx
+20
-6
No files found.
tests/errors/e_powop.pyx
View file @
6e54e1e6
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)
"""
tests/run/powop.pyx
View file @
6e54e1e6
...
...
@@ -8,17 +8,25 @@ __doc__ = u"""
>>> h(4)
625
>>> constant_py() == 2
L
** 10
>>> constant_py() == 2 ** 10
True
>>> constant_long() == 2
L
** 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
=
(
<
object
>
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment