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
80ff11eb
Commit
80ff11eb
authored
Apr 07, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test cases for type inference in generators
parent
292c1eb0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
tests/run/generator_type_inference.pyx
tests/run/generator_type_inference.pyx
+40
-1
No files found.
tests/run/generator_type_inference.pyx
View file @
80ff11eb
...
@@ -5,9 +5,48 @@ cimport cython
...
@@ -5,9 +5,48 @@ cimport cython
def
test_type_inference
():
def
test_type_inference
():
"""
"""
>>>
[ item for item in test_type_inference() ]
>>>
list(test_type_inference())
[(2.0, 'double'), (2.0, 'double'), (2.0, 'double')]
[(2.0, 'double'), (2.0, 'double'), (2.0, 'double')]
"""
"""
x
=
1.0
x
=
1.0
for
i
in
range
(
3
):
for
i
in
range
(
3
):
yield
x
*
2.0
,
cython
.
typeof
(
x
)
yield
x
*
2.0
,
cython
.
typeof
(
x
)
def
test_unicode_loop
():
"""
>>> chars = list(test_unicode_loop())
1 Py_UCS4
2 Py_UCS4
2 Py_UCS4
2 Py_UCS4
2 Py_UCS4
>>> len(chars)
4
>>> ''.join(chars) == 'abcd'
True
"""
ustr
=
u'abcd'
print
1
,
cython
.
typeof
(
ustr
[
0
])
for
c
in
ustr
:
print
2
,
cython
.
typeof
(
c
)
yield
c
def
test_nonlocal_disables_inference
():
"""
>>> chars = list(test_nonlocal_disables_inference())
1 Python object
2 Python object
2 Python object
>>> len(chars)
2
>>> ''.join(chars) == 'ab'
True
"""
ustr
=
u'ab'
print
1
,
cython
.
typeof
(
ustr
[
0
])
def
gen
():
nonlocal
ustr
for
c
in
ustr
:
print
2
,
cython
.
typeof
(
c
)
yield
c
return
gen
()
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