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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
5de4e6bd
Commit
5de4e6bd
authored
Dec 28, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More overflow testing.
parent
9d493a05
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
5 deletions
+35
-5
tests/run/overflow_check.pxi
tests/run/overflow_check.pxi
+23
-5
tests/run/overflow_check_int.pyx
tests/run/overflow_check_int.pyx
+3
-0
tests/run/overflow_check_longlong.pyx
tests/run/overflow_check_longlong.pyx
+3
-0
tests/run/overflow_check_uint.pyx
tests/run/overflow_check_uint.pyx
+3
-0
tests/run/overflow_check_ulonglong.pyx
tests/run/overflow_check_ulonglong.pyx
+3
-0
No files found.
tests/run/overflow_check.pxi
View file @
5de4e6bd
...
...
@@ -106,12 +106,12 @@ def test_mul(INT a, INT b):
return
int
(
a
*
b
)
@
cython
.
overflowcheck
(
True
)
def
test_nested
(
INT
a
,
INT
b
,
INT
c
):
def
test_nested
_add
(
INT
a
,
INT
b
,
INT
c
):
"""
>>> test_nested(1, 2, 3)
>>> test_nested
_add
(1, 2, 3)
6
>>> expect_overflow(test_nested, half + 1, half + 1, half + 1)
>>> expect_overflow(test_nested, half - 1, half - 1, half - 1)
>>> expect_overflow(test_nested
_add
, half + 1, half + 1, half + 1)
>>> expect_overflow(test_nested
_add
, half - 1, half - 1, half - 1)
"""
return
int
(
a
+
b
+
c
)
...
...
@@ -154,6 +154,25 @@ cdef INT called(INT value):
print
(
"called(%s)"
%
format
(
value
))
return
value
@
cython
.
overflowcheck
(
True
)
def
test_nested
(
INT
a
,
INT
b
,
INT
c
,
INT
d
):
"""
>>> test_nested_func(1, 2, 3)
called(5)
6
>>> expect_overflow(test_nested, half, half, 1, 1)
>>> expect_overflow(test_nested, half, 1, half, half)
>>> expect_overflow(test_nested, half, 2, half, 2)
>>> print(format(test_nested(half, 2, 0, 1)))
half + half - 0
>>> print(format(test_nested(1, 0, half, 2)))
half + half - 0
>>> print(format(test_nested(half, 1, 1, half)))
half + half - 0
"""
return
int
(
a
*
b
+
c
*
d
)
@
cython
.
overflowcheck
(
True
)
def
test_nested_func
(
INT
a
,
INT
b
,
INT
c
):
"""
...
...
@@ -166,7 +185,6 @@ def test_nested_func(INT a, INT b, INT c):
>>> print(format(test_nested_func(1, half - 1, half - 1)))
called(half + half - 2)
half + half - 1
>>>
"""
return
int
(
a
+
called
(
b
+
c
))
...
...
tests/run/overflow_check_int.pyx
View file @
5de4e6bd
# cython: overflowcheck.fold = True
ctypedef
int
INT
include
"overflow_check.pxi"
tests/run/overflow_check_longlong.pyx
View file @
5de4e6bd
# cython: overflowcheck.fold = False
ctypedef
long
long
INT
include
"overflow_check.pxi"
tests/run/overflow_check_uint.pyx
View file @
5de4e6bd
# cython: overflowcheck.fold = False
ctypedef
unsigned
int
INT
include
"overflow_check.pxi"
tests/run/overflow_check_ulonglong.pyx
View file @
5de4e6bd
# cython: overflowcheck.fold = True
ctypedef
unsigned
long
long
INT
include
"overflow_check.pxi"
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