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
ee0f9802
Commit
ee0f9802
authored
Oct 04, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PEP-8-ified the decorator names for parse tree assertions, added a test case
parent
3a712b6e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
37 deletions
+54
-37
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+4
-4
Cython/TestUtils.py
Cython/TestUtils.py
+6
-8
tests/errors/tree_assert.pyx
tests/errors/tree_assert.pyx
+17
-0
tests/run/dictcomp.pyx
tests/run/dictcomp.pyx
+6
-4
tests/run/enumerate_T316.pyx
tests/run/enumerate_T316.pyx
+10
-10
tests/run/for_in_range_T372.pyx
tests/run/for_in_range_T372.pyx
+8
-8
tests/run/setcomp.pyx
tests/run/setcomp.pyx
+3
-3
No files found.
Cython/Compiler/Options.py
View file @
ee0f9802
...
@@ -71,8 +71,8 @@ option_defaults = {
...
@@ -71,8 +71,8 @@ option_defaults = {
'doctesthack'
:
False
,
'doctesthack'
:
False
,
# test support
# test support
'test
AssertPathE
xists'
:
[],
'test
_assert_path_e
xists'
:
[],
'test
FailIfPathE
xists'
:
[],
'test
_fail_if_path_e
xists'
:
[],
}
}
# Override types possibilities above, if needed
# Override types possibilities above, if needed
...
@@ -85,8 +85,8 @@ for key, val in option_defaults.items():
...
@@ -85,8 +85,8 @@ for key, val in option_defaults.items():
option_scopes
=
{
# defaults to available everywhere
option_scopes
=
{
# defaults to available everywhere
# 'module', 'function', 'class', 'with statement'
# 'module', 'function', 'class', 'with statement'
'doctesthack'
:
(
'module'
,),
'doctesthack'
:
(
'module'
,),
'test
AssertPathE
xists'
:
(
'function'
,),
'test
_assert_path_e
xists'
:
(
'function'
,),
'test
FailIfPathE
xists'
:
(
'function'
,),
'test
_fail_if_path_e
xists'
:
(
'function'
,),
}
}
def
parse_option_value
(
name
,
value
):
def
parse_option_value
(
name
,
value
):
...
...
Cython/TestUtils.py
View file @
ee0f9802
...
@@ -148,20 +148,18 @@ class TreeAssertVisitor(VisitorTransform):
...
@@ -148,20 +148,18 @@ class TreeAssertVisitor(VisitorTransform):
def
visit_CompilerDirectivesNode
(
self
,
node
):
def
visit_CompilerDirectivesNode
(
self
,
node
):
directives
=
node
.
directives
directives
=
node
.
directives
if
'test
AssertPathE
xists'
in
directives
:
if
'test
_assert_path_e
xists'
in
directives
:
for
path
in
directives
[
'test
AssertPathE
xists'
]:
for
path
in
directives
[
'test
_assert_path_e
xists'
]:
if
TreePath
.
find_first
(
node
,
path
)
is
None
:
if
TreePath
.
find_first
(
node
,
path
)
is
None
:
Errors
.
error
(
Errors
.
error
(
node
.
pos
,
node
.
pos
,
"Expected path '%s' not found in result tree of node %r"
%
(
"Expected path '%s' not found in result tree"
%
path
)
path
,
node
.
body
))
if
'test_fail_if_path_exists'
in
directives
:
if
'testFailIfPathExists'
in
directives
:
for
path
in
directives
[
'test_fail_if_path_exists'
]:
for
path
in
directives
[
'testFailIfPathExists'
]:
if
TreePath
.
find_first
(
node
,
path
)
is
not
None
:
if
TreePath
.
find_first
(
node
,
path
)
is
not
None
:
Errors
.
error
(
Errors
.
error
(
node
.
pos
,
node
.
pos
,
"Unexpected path '%s' found in result tree of node %r"
%
(
"Unexpected path '%s' found in result tree"
%
path
)
path
,
node
.
body
))
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
...
...
tests/errors/tree_assert.pyx
0 → 100644
View file @
ee0f9802
cimport
cython
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
,
"//NameNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
,
"//ComprehensionNode//FuncDefNode"
)
def
test
():
object
()
_ERRORS
=
u"""
8:0: Expected path '//ComprehensionNode' not found in result tree
8:0: Expected path '//ComprehensionNode//FuncDefNode' not found in result tree
8:0: Unexpected path '//NameNode' found in result tree
8:0: Unexpected path '//SimpleCallNode' found in result tree
"""
tests/run/dictcomp.pyx
View file @
ee0f9802
...
@@ -22,10 +22,12 @@ def smoketest_dict():
...
@@ -22,10 +22,12 @@ def smoketest_dict():
for
x
in
range
(
5
)
for
x
in
range
(
5
)
if
x
%
2
==
0
}
if
x
%
2
==
0
}
@
cython
.
testFailIfPathExists
(
"//ComprehensionNode//ComprehensionAppendNode"
,
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//ComprehensionNode"
)
"//ComprehensionNode//ComprehensionAppendNode"
,
@
cython
.
testAssertPathExists
(
"//ComprehensionNode"
,
"//SimpleCallNode//ComprehensionNode"
)
"//ComprehensionNode//DictComprehensionAppendNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
,
"//ComprehensionNode//DictComprehensionAppendNode"
)
def
smoketest_list
():
def
smoketest_list
():
return
dict
([
(
x
+
2
,
x
*
2
)
return
dict
([
(
x
+
2
,
x
*
2
)
for
x
in
range
(
5
)
for
x
in
range
(
5
)
...
...
tests/run/enumerate_T316.pyx
View file @
ee0f9802
...
@@ -65,24 +65,24 @@ __doc__ = u"""
...
@@ -65,24 +65,24 @@ __doc__ = u"""
cimport
cython
cimport
cython
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_py_enumerate
():
def
go_py_enumerate
():
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
print
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate
():
def
go_c_enumerate
():
cdef
int
i
,
k
cdef
int
i
,
k
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
print
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate_step
():
def
go_c_enumerate_step
():
cdef
int
i
,
k
cdef
int
i
,
k
for
i
,
k
in
enumerate
(
range
(
1
,
7
,
2
)):
for
i
,
k
in
enumerate
(
range
(
1
,
7
,
2
)):
print
i
,
k
print
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
py_enumerate_dict
(
dict
d
):
def
py_enumerate_dict
(
dict
d
):
cdef
int
i
=
55
cdef
int
i
=
55
k
=
99
k
=
99
...
@@ -90,7 +90,7 @@ def py_enumerate_dict(dict d):
...
@@ -90,7 +90,7 @@ def py_enumerate_dict(dict d):
print
i
,
k
print
i
,
k
print
u"::"
,
i
,
k
print
u"::"
,
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode"
)
def
py_enumerate_break
(
*
t
):
def
py_enumerate_break
(
*
t
):
i
,
k
=
55
,
99
i
,
k
=
55
,
99
for
i
,
k
in
enumerate
(
t
):
for
i
,
k
in
enumerate
(
t
):
...
@@ -98,7 +98,7 @@ def py_enumerate_break(*t):
...
@@ -98,7 +98,7 @@ def py_enumerate_break(*t):
break
break
print
u"::"
,
i
,
k
print
u"::"
,
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode"
)
def
py_enumerate_return
(
*
t
):
def
py_enumerate_return
(
*
t
):
i
,
k
=
55
,
99
i
,
k
=
55
,
99
for
i
,
k
in
enumerate
(
t
):
for
i
,
k
in
enumerate
(
t
):
...
@@ -106,7 +106,7 @@ def py_enumerate_return(*t):
...
@@ -106,7 +106,7 @@ def py_enumerate_return(*t):
return
return
print
u"::"
,
i
,
k
print
u"::"
,
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode"
)
def
py_enumerate_continue
(
*
t
):
def
py_enumerate_continue
(
*
t
):
i
,
k
=
55
,
99
i
,
k
=
55
,
99
for
i
,
k
in
enumerate
(
t
):
for
i
,
k
in
enumerate
(
t
):
...
@@ -114,7 +114,7 @@ def py_enumerate_continue(*t):
...
@@ -114,7 +114,7 @@ def py_enumerate_continue(*t):
continue
continue
print
u"::"
,
i
,
k
print
u"::"
,
i
,
k
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
empty_c_enumerate
():
def
empty_c_enumerate
():
cdef
int
i
=
55
,
k
=
99
cdef
int
i
=
55
,
k
=
99
for
i
,
k
in
enumerate
(
range
(
0
)):
for
i
,
k
in
enumerate
(
range
(
0
)):
...
@@ -126,12 +126,12 @@ def single_target_enumerate():
...
@@ -126,12 +126,12 @@ def single_target_enumerate():
for
t
in
enumerate
(
range
(
1
,
5
)):
for
t
in
enumerate
(
range
(
1
,
5
)):
print
t
[
0
],
t
[
1
]
print
t
[
0
],
t
[
1
]
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
multi_enumerate
():
def
multi_enumerate
():
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
print
a
,
b
,
c
,
d
print
a
,
b
,
c
,
d
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode"
)
def
multi_c_enumerate
():
def
multi_c_enumerate
():
cdef
int
a
,
b
,
c
,
d
cdef
int
a
,
b
,
c
,
d
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
...
...
tests/run/for_in_range_T372.pyx
View file @
ee0f9802
...
@@ -15,8 +15,8 @@ __doc__ = u"""
...
@@ -15,8 +15,8 @@ __doc__ = u"""
cimport
cython
cimport
cython
@
cython
.
test
AssertPathE
xists
(
"//ForFromStatNode"
)
@
cython
.
test
_assert_path_e
xists
(
"//ForFromStatNode"
)
@
cython
.
test
FailIfPathE
xists
(
"//ForInStatNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//ForInStatNode"
)
def
test_modify
():
def
test_modify
():
cdef
int
i
,
n
=
5
cdef
int
i
,
n
=
5
for
i
in
range
(
n
):
for
i
in
range
(
n
):
...
@@ -25,8 +25,8 @@ def test_modify():
...
@@ -25,8 +25,8 @@ def test_modify():
print
print
return
i
,
n
return
i
,
n
@
cython
.
test
AssertPathE
xists
(
"//ForFromStatNode"
)
@
cython
.
test
_assert_path_e
xists
(
"//ForFromStatNode"
)
@
cython
.
test
FailIfPathE
xists
(
"//ForInStatNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//ForInStatNode"
)
def
test_fix
():
def
test_fix
():
cdef
int
i
cdef
int
i
for
i
in
range
(
5
):
for
i
in
range
(
5
):
...
@@ -34,8 +34,8 @@ def test_fix():
...
@@ -34,8 +34,8 @@ def test_fix():
print
print
return
i
return
i
@
cython
.
test
AssertPathE
xists
(
"//ForFromStatNode"
)
@
cython
.
test
_assert_path_e
xists
(
"//ForFromStatNode"
)
@
cython
.
test
FailIfPathE
xists
(
"//ForInStatNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//ForInStatNode"
)
def
test_break
():
def
test_break
():
cdef
int
i
,
n
=
5
cdef
int
i
,
n
=
5
for
i
in
range
(
n
):
for
i
in
range
(
n
):
...
@@ -46,8 +46,8 @@ def test_break():
...
@@ -46,8 +46,8 @@ def test_break():
print
print
return
i
,
n
return
i
,
n
@
cython
.
test
AssertPathE
xists
(
"//ForFromStatNode"
)
@
cython
.
test
_assert_path_e
xists
(
"//ForFromStatNode"
)
@
cython
.
test
FailIfPathE
xists
(
"//ForInStatNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//ForInStatNode"
)
def
test_return
():
def
test_return
():
cdef
int
i
,
n
=
5
cdef
int
i
,
n
=
5
for
i
in
range
(
n
):
for
i
in
range
(
n
):
...
...
tests/run/setcomp.pyx
View file @
ee0f9802
...
@@ -27,9 +27,9 @@ def smoketest_set():
...
@@ -27,9 +27,9 @@ def smoketest_set():
for
x
in
range
(
5
)
for
x
in
range
(
5
)
if
x
%
2
==
0
}
if
x
%
2
==
0
}
@
cython
.
test
FailIfPathE
xists
(
"//SimpleCallNode//ComprehensionNode"
)
@
cython
.
test
_fail_if_path_e
xists
(
"//SimpleCallNode//ComprehensionNode"
)
@
cython
.
test
AssertPathE
xists
(
"//ComprehensionNode"
,
@
cython
.
test
_assert_path_e
xists
(
"//ComprehensionNode"
,
"//ComprehensionNode//ComprehensionAppendNode"
)
"//ComprehensionNode//ComprehensionAppendNode"
)
def
smoketest_list
():
def
smoketest_list
():
return
set
([
x
*
2
return
set
([
x
*
2
for
x
in
range
(
5
)
for
x
in
range
(
5
)
...
...
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