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
Kirill Smelkov
cython
Commits
d283bd6c
Commit
d283bd6c
authored
Sep 27, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate functions in test for readability.
parent
0fb73f66
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
tests/run/cython3.pyx
tests/run/cython3.pyx
+15
-0
No files found.
tests/run/cython3.pyx
View file @
d283bd6c
...
@@ -275,6 +275,7 @@ def exec3_function(cmd):
...
@@ -275,6 +275,7 @@ def exec3_function(cmd):
exec
(
cmd
,
g
,
l
)
exec
(
cmd
,
g
,
l
)
return
l
return
l
def
exec2_function
(
cmd
):
def
exec2_function
(
cmd
):
"""
"""
>>> exec2_function('a = 1+1')['a']
>>> exec2_function('a = 1+1')['a']
...
@@ -284,6 +285,7 @@ def exec2_function(cmd):
...
@@ -284,6 +285,7 @@ def exec2_function(cmd):
exec
(
cmd
,
g
)
exec
(
cmd
,
g
)
return
g
return
g
EXEC_GLOBAL
=
[
5
]
EXEC_GLOBAL
=
[
5
]
def
exec1_function
(
cmd
):
def
exec1_function
(
cmd
):
...
@@ -295,6 +297,7 @@ def exec1_function(cmd):
...
@@ -295,6 +297,7 @@ def exec1_function(cmd):
exec
(
cmd
)
exec
(
cmd
)
return
EXEC_GLOBAL
[
old
:]
return
EXEC_GLOBAL
[
old
:]
ustring
=
"abcdefg"
ustring
=
"abcdefg"
def
unicode_literals
():
def
unicode_literals
():
...
@@ -306,6 +309,7 @@ def unicode_literals():
...
@@ -306,6 +309,7 @@ def unicode_literals():
print
(
isinstance
(
ustring
,
unicode
)
or
type
(
ustring
))
print
(
isinstance
(
ustring
,
unicode
)
or
type
(
ustring
))
return
ustring
return
ustring
def
str_type_is_unicode
():
def
str_type_is_unicode
():
"""
"""
>>> str_type, s = str_type_is_unicode()
>>> str_type, s = str_type_is_unicode()
...
@@ -319,6 +323,7 @@ def str_type_is_unicode():
...
@@ -319,6 +323,7 @@ def str_type_is_unicode():
cdef
str
s
=
'abc'
cdef
str
s
=
'abc'
return
str
,
s
return
str
,
s
def
loop_over_unicode_literal
():
def
loop_over_unicode_literal
():
"""
"""
>>> print( loop_over_unicode_literal() )
>>> print( loop_over_unicode_literal() )
...
@@ -372,6 +377,7 @@ def list_comp_with_lambda():
...
@@ -372,6 +377,7 @@ def list_comp_with_lambda():
assert
x
==
'abc'
# don't leak in Py3 code
assert
x
==
'abc'
# don't leak in Py3 code
return
result
return
result
module_level_lc
=
[
module_level_loopvar
*
2
for
module_level_loopvar
in
range
(
4
)
]
module_level_lc
=
[
module_level_loopvar
*
2
for
module_level_loopvar
in
range
(
4
)
]
def
list_comp_module_level
():
def
list_comp_module_level
():
"""
"""
...
@@ -382,6 +388,7 @@ def list_comp_module_level():
...
@@ -382,6 +388,7 @@ def list_comp_module_level():
NameError: ...name 'module_level_loopvar' is not defined
NameError: ...name 'module_level_loopvar' is not defined
"""
"""
module_level_list_genexp
=
list
(
module_level_genexp_loopvar
*
2
for
module_level_genexp_loopvar
in
range
(
4
))
module_level_list_genexp
=
list
(
module_level_genexp_loopvar
*
2
for
module_level_genexp_loopvar
in
range
(
4
))
def
genexpr_module_level
():
def
genexpr_module_level
():
"""
"""
...
@@ -392,6 +399,7 @@ def genexpr_module_level():
...
@@ -392,6 +399,7 @@ def genexpr_module_level():
NameError: ...name 'module_level_genexp_loopvar' is not defined
NameError: ...name 'module_level_genexp_loopvar' is not defined
"""
"""
def
list_comp_unknown_type
(
l
):
def
list_comp_unknown_type
(
l
):
"""
"""
>>> list_comp_unknown_type(range(5))
>>> list_comp_unknown_type(range(5))
...
@@ -399,6 +407,7 @@ def list_comp_unknown_type(l):
...
@@ -399,6 +407,7 @@ def list_comp_unknown_type(l):
"""
"""
return
[
x
*
2
for
x
in
l
if
x
%
2
==
0
]
return
[
x
*
2
for
x
in
l
if
x
%
2
==
0
]
def
listcomp_as_condition
(
sequence
):
def
listcomp_as_condition
(
sequence
):
"""
"""
>>> listcomp_as_condition(['a', 'b', '+'])
>>> listcomp_as_condition(['a', 'b', '+'])
...
@@ -412,6 +421,7 @@ def listcomp_as_condition(sequence):
...
@@ -412,6 +421,7 @@ def listcomp_as_condition(sequence):
return
True
return
True
return
False
return
False
def
set_comp
():
def
set_comp
():
"""
"""
>>> sorted(set_comp())
>>> sorted(set_comp())
...
@@ -422,6 +432,7 @@ def set_comp():
...
@@ -422,6 +432,7 @@ def set_comp():
assert
x
==
'abc'
# don't leak
assert
x
==
'abc'
# don't leak
return
result
return
result
def
dict_comp
():
def
dict_comp
():
"""
"""
>>> sorted(dict_comp().items())
>>> sorted(dict_comp().items())
...
@@ -432,6 +443,7 @@ def dict_comp():
...
@@ -432,6 +443,7 @@ def dict_comp():
assert
x
==
'abc'
# don't leak
assert
x
==
'abc'
# don't leak
return
result
return
result
# in Python 3, d.keys/values/items() are the iteration methods
# in Python 3, d.keys/values/items() are the iteration methods
@
cython
.
test_assert_path_exists
(
@
cython
.
test_assert_path_exists
(
"//WhileStatNode"
,
"//WhileStatNode"
,
...
@@ -457,6 +469,7 @@ def dict_iter(dict d):
...
@@ -457,6 +469,7 @@ def dict_iter(dict d):
items
=
[
item
for
item
in
d
.
items
()
]
items
=
[
item
for
item
in
d
.
items
()
]
return
keys
,
values
,
items
return
keys
,
values
,
items
@
cython
.
test_assert_path_exists
(
@
cython
.
test_assert_path_exists
(
"//WhileStatNode"
,
"//WhileStatNode"
,
"//WhileStatNode//DictIterationNextNode"
)
"//WhileStatNode//DictIterationNextNode"
)
...
@@ -480,6 +493,7 @@ def dict_iter_new_dict():
...
@@ -480,6 +493,7 @@ def dict_iter_new_dict():
items
=
[
item
for
item
in
{
11
:
1
,
22
:
2
,
33
:
3
}.
items
()
]
items
=
[
item
for
item
in
{
11
:
1
,
22
:
2
,
33
:
3
}.
items
()
]
return
dict_keys
,
keys
,
values
,
items
return
dict_keys
,
keys
,
values
,
items
def
int_literals
():
def
int_literals
():
"""
"""
>>> int_literals()
>>> int_literals()
...
@@ -493,6 +507,7 @@ def int_literals():
...
@@ -493,6 +507,7 @@ def int_literals():
print
(
cython
.
typeof
(
1
UL
))
print
(
cython
.
typeof
(
1
UL
))
print
(
cython
.
typeof
(
10000000000000
UL
))
print
(
cython
.
typeof
(
10000000000000
UL
))
def
annotation_syntax
(
a
:
"test new test"
,
b
:
"other"
=
2
,
*
args
:
"ARGS"
,
**
kwargs
:
"KWARGS"
)
->
"ret"
:
def
annotation_syntax
(
a
:
"test new test"
,
b
:
"other"
=
2
,
*
args
:
"ARGS"
,
**
kwargs
:
"KWARGS"
)
->
"ret"
:
"""
"""
>>> annotation_syntax(1)
>>> annotation_syntax(1)
...
...
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