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
6f68503a
Commit
6f68503a
authored
Nov 17, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for constant tuple caching
parent
9a9ed566
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
tests/run/tuple_constants.pyx
tests/run/tuple_constants.pyx
+108
-0
No files found.
tests/run/tuple_constants.pyx
0 → 100644
View file @
6f68503a
cimport
cython
module_level_tuple
=
(
1
,
2
,
3
)
def
return_module_level_tuple
():
"""
>>> return_module_level_tuple()
(1, 2, 3)
"""
return
module_level_tuple
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_empty_tuple
():
"""
>>> return_empty_tuple()
()
"""
return
()
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_constant_tuple1
():
"""
>>> return_constant_tuple1()
(1,)
"""
return
(
1
,)
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_folded_tuple
():
"""
>>> return_folded_tuple()
(1, 2, 3)
"""
return
(
1
,
1
+
1
,
1
+
1
+
1
)
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_nested_tuple
():
"""
>>> return_nested_tuple()
(1, (2, 3), (3, (4, 5)))
"""
return
(
1
,
(
2
,
3
),
(
3
,
(
4
,
5
)))
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
constant_tuple1
():
"""
>>> constant_tuple1()
(1,)
"""
tuple1
=
(
1
,)
return
tuple1
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_constant_tuple2
():
"""
>>> return_constant_tuple2()
(1, 2)
"""
return
(
1
,
2
)
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_constant_tuple_strings
():
"""
>>> return_constant_tuple_strings()
('tuple_1', 'bc', 'tuple_2')
"""
return
(
'tuple_1'
,
'bc'
,
'tuple_2'
)
@
cython
.
test_assert_path_exists
(
"//TupleNode"
,
"//TupleNode[@is_literal = true]"
)
@
cython
.
test_fail_if_path_exists
(
"//TupleNode[@is_literal = false]"
)
def
return_constant_tuples_string_types
():
"""
>>> a,b,c = return_constant_tuples_string_types()
>>> a is b
False
>>> a is c
False
>>> b is c
False
"""
return
(
'a'
,
'bc'
),
(
u'a'
,
u'bc'
),
(
b'a'
,
b'bc'
)
@
cython
.
test_assert_path_exists
(
"//ReturnStatNode//TupleNode"
,
"//ReturnStatNode//TupleNode[@is_literal = false]"
)
@
cython
.
test_fail_if_path_exists
(
"//ReturnStatNode//TupleNode[@is_literal = true]"
)
def
return_nonconstant_tuple
():
"""
>>> return_nonconstant_tuple()
('a', 1, 'd')
"""
a
=
eval
(
"1"
)
return
(
'a'
,
a
,
'd'
)
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