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
Boxiang Sun
cython
Commits
92f424fc
Commit
92f424fc
authored
May 25, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some simple run tests for control-flow
parent
048270fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
tests/run/uninitialized.pyx
tests/run/uninitialized.pyx
+60
-0
No files found.
tests/run/uninitialized.pyx
0 → 100644
View file @
92f424fc
# mode: run
# tag: control-flow, uninitialized
def
conditional
(
cond
):
"""
>>> conditional(True)
[]
>>> conditional(False)
Traceback (most recent call last):
...
UnboundLocalError: a
"""
if
cond
:
a
=
[]
return
a
def
inside_loop
(
iter
):
"""
>>> inside_loop([1,2,3])
3
>>> inside_loop([])
Traceback (most recent call last):
...
UnboundLocalError: i
"""
for
i
in
iter
:
pass
return
i
def
try_except
(
cond
):
"""
>>> try_except(True)
[]
>>> try_except(False)
Traceback (most recent call last):
...
UnboundLocalError: a
"""
try
:
if
cond
:
a
=
[]
raise
ValueError
except
ValueError
:
return
a
def
try_finally
(
cond
):
"""
>>> try_finally(True)
[]
>>> try_finally(False)
Traceback (most recent call last):
...
UnboundLocalError: a
"""
try
:
if
cond
:
a
=
[]
raise
ValueError
finally
:
return
a
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