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
1fcaf853
Commit
1fcaf853
authored
May 21, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ptrdif_t test
parent
3087d7fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-1
tests/run/ptrdiff_t.pyx
tests/run/ptrdiff_t.pyx
+55
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
1fcaf853
...
...
@@ -3456,7 +3456,7 @@ c_py_hash_t_type = CPyHashTType(RANK_LONG+0.5, SIGNED)
c_py_ssize_t_type
=
CPySSizeTType
(
RANK_LONG
+
0.5
,
SIGNED
)
c_ssize_t_type
=
CSSizeTType
(
RANK_LONG
+
0.5
,
SIGNED
)
c_size_t_type
=
CSizeTType
(
RANK_LONG
+
0.5
,
UNSIGNED
)
c_ptrdiff_t_type
=
CPtrdiffTType
(
RANK_LONG
+
0.
2
5
,
SIGNED
)
c_ptrdiff_t_type
=
CPtrdiffTType
(
RANK_LONG
+
0.
7
5
,
SIGNED
)
c_null_ptr_type
=
CNullPtrType
(
c_void_type
)
c_void_ptr_type
=
CPtrType
(
c_void_type
)
...
...
tests/run/ptrdiff_t.pyx
0 → 100644
View file @
1fcaf853
from
cython
cimport
typeof
def
test
(
ptrdiff_t
i
):
"""
>>> test(0)
0
>>> test(1)
1
>>> test(2)
2
>>> test(-1)
-1
>>> test(-2)
-2
>>> str(test((1<<31)-1))
'2147483647'
"""
return
i
cdef
class
A
:
"""
>>> try: test(1<<200)
... except (OverflowError, TypeError): print("ERROR")
ERROR
>>> a = A(1,2)
>>> a.a == 1
True
>>> a.b == 2
True
>>> a.foo(5)
5
>>> try: a.foo(1<<200)
... except (OverflowError, TypeError): print("ERROR")
ERROR
"""
cdef
public
ptrdiff_t
a
cdef
readonly
ptrdiff_t
b
def
__init__
(
self
,
ptrdiff_t
a
,
object
b
):
self
.
a
=
a
self
.
b
=
b
cpdef
ptrdiff_t
foo
(
self
,
ptrdiff_t
x
):
cdef
object
o
=
x
return
o
def
test_types
():
"""
>>> test_types()
"""
cdef
int
a
=
1
,
b
=
2
assert
typeof
(
&
a
-
&
b
)
==
"ptrdiff_t"
,
typeof
(
&
a
-
&
b
)
assert
typeof
((
&
a
-
&
b
)
+
1
)
==
"ptrdiff_t"
,
typeof
((
&
a
-
&
b
)
+
1
)
assert
typeof
(
&
a
+
(
&
b
-
&
a
))
==
"int *"
,
typeof
(
&
a
+
(
&
b
-
&
a
))
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