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
19bb02e7
Commit
19bb02e7
authored
Feb 15, 2012
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testcase for function call as default argument
parent
844bee64
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
tests/run/cyfunction_defaults.py
tests/run/cyfunction_defaults.py
+26
-0
No files found.
tests/run/cyfunction_defaults.py
View file @
19bb02e7
...
...
@@ -59,3 +59,29 @@ def test_defaults_nonliteral():
return
c
,
d
ret
.
append
(
foo
)
return
ret
_counter
=
0
def
counter
():
global
_counter
_counter
+=
1
return
_counter
def
test_defaults_nonliteral_func_call
(
f
):
"""
>>> f = test_defaults_nonliteral_func_call(counter)
>>> f()
1
>>> get_defaults(f)
(1,)
>>> f = test_defaults_nonliteral_func_call(lambda: list())
>>> f()
[]
>>> get_defaults(f)
([],)
>>> get_defaults(f)[0] is f()
True
"""
def
func
(
a
=
f
()):
return
a
return
func
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