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
ffc32b04
Commit
ffc32b04
authored
Jun 18, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed test case
parent
e76197d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
Cython/Compiler/Tests/TestTreeFragment.py
Cython/Compiler/Tests/TestTreeFragment.py
+13
-16
No files found.
Cython/Compiler/Tests/TestTreeFragment.py
View file @
ffc32b04
from
Cython.TestUtils
import
CythonTest
from
Cython.TestUtils
import
CythonTest
from
Cython.Compiler.TreeFragment
import
*
from
Cython.Compiler.TreeFragment
import
*
from
Cython.Compiler.Nodes
import
*
from
Cython.Compiler.Nodes
import
*
import
Cython.Compiler.Naming
as
Naming
class
TestTreeFragments
(
CythonTest
):
class
TestTreeFragments
(
CythonTest
):
def
test_basic
(
self
):
def
test_basic
(
self
):
...
@@ -12,15 +13,15 @@ class TestTreeFragments(CythonTest):
...
@@ -12,15 +13,15 @@ class TestTreeFragments(CythonTest):
F
=
self
.
fragment
(
u"if True: x = 4"
)
F
=
self
.
fragment
(
u"if True: x = 4"
)
T1
=
F
.
root
T1
=
F
.
root
T2
=
F
.
copy
()
T2
=
F
.
copy
()
self
.
assertEqual
(
"x"
,
T2
.
body
.
if_clauses
[
0
].
body
.
lhs
.
name
)
self
.
assertEqual
(
"x"
,
T2
.
stats
[
0
]
.
if_clauses
[
0
].
body
.
lhs
.
name
)
T2
.
body
.
if_clauses
[
0
].
body
.
lhs
.
name
=
"other"
T2
.
stats
[
0
]
.
if_clauses
[
0
].
body
.
lhs
.
name
=
"other"
self
.
assertEqual
(
"x"
,
T1
.
body
.
if_clauses
[
0
].
body
.
lhs
.
name
)
self
.
assertEqual
(
"x"
,
T1
.
stats
[
0
]
.
if_clauses
[
0
].
body
.
lhs
.
name
)
def
test_substitutions_are_copied
(
self
):
def
test_substitutions_are_copied
(
self
):
T
=
self
.
fragment
(
u"y + y"
).
substitute
({
"y"
:
NameNode
(
pos
=
None
,
name
=
"x"
)})
T
=
self
.
fragment
(
u"y + y"
).
substitute
({
"y"
:
NameNode
(
pos
=
None
,
name
=
"x"
)})
self
.
assertEqual
(
"x"
,
T
.
body
.
expr
.
operand1
.
name
)
self
.
assertEqual
(
"x"
,
T
.
stats
[
0
]
.
expr
.
operand1
.
name
)
self
.
assertEqual
(
"x"
,
T
.
body
.
expr
.
operand2
.
name
)
self
.
assertEqual
(
"x"
,
T
.
stats
[
0
]
.
expr
.
operand2
.
name
)
self
.
assert_
(
T
.
body
.
expr
.
operand1
is
not
T
.
body
.
expr
.
operand2
)
self
.
assert_
(
T
.
stats
[
0
].
expr
.
operand1
is
not
T
.
stats
[
0
]
.
expr
.
operand2
)
def
test_substitution
(
self
):
def
test_substitution
(
self
):
F
=
self
.
fragment
(
u"x = 4"
)
F
=
self
.
fragment
(
u"x = 4"
)
...
@@ -32,7 +33,7 @@ class TestTreeFragments(CythonTest):
...
@@ -32,7 +33,7 @@ class TestTreeFragments(CythonTest):
F
=
self
.
fragment
(
u"PASS"
)
F
=
self
.
fragment
(
u"PASS"
)
pass_stat
=
PassStatNode
(
pos
=
None
)
pass_stat
=
PassStatNode
(
pos
=
None
)
T
=
F
.
substitute
({
"PASS"
:
pass_stat
})
T
=
F
.
substitute
({
"PASS"
:
pass_stat
})
self
.
assert_
(
isinstance
(
T
.
body
,
PassStatNode
),
T
.
body
)
self
.
assert_
(
isinstance
(
T
.
stats
[
0
],
PassStatNode
),
T
)
def
test_pos_is_transferred
(
self
):
def
test_pos_is_transferred
(
self
):
F
=
self
.
fragment
(
u"""
F
=
self
.
fragment
(
u"""
...
@@ -40,8 +41,8 @@ class TestTreeFragments(CythonTest):
...
@@ -40,8 +41,8 @@ class TestTreeFragments(CythonTest):
x = u * v ** w
x = u * v ** w
"""
)
"""
)
T
=
F
.
substitute
({
"v"
:
NameNode
(
pos
=
None
,
name
=
"a"
)})
T
=
F
.
substitute
({
"v"
:
NameNode
(
pos
=
None
,
name
=
"a"
)})
v
=
F
.
root
.
body
.
stats
[
1
].
rhs
.
operand2
.
operand1
v
=
F
.
root
.
stats
[
1
].
rhs
.
operand2
.
operand1
a
=
T
.
body
.
stats
[
1
].
rhs
.
operand2
.
operand1
a
=
T
.
stats
[
1
].
rhs
.
operand2
.
operand1
self
.
assertEquals
(
v
.
pos
,
a
.
pos
)
self
.
assertEquals
(
v
.
pos
,
a
.
pos
)
def
test_temps
(
self
):
def
test_temps
(
self
):
...
@@ -50,15 +51,11 @@ class TestTreeFragments(CythonTest):
...
@@ -50,15 +51,11 @@ class TestTreeFragments(CythonTest):
x = TMP
x = TMP
"""
)
"""
)
T
=
F
.
substitute
(
temps
=
[
u"TMP"
])
T
=
F
.
substitute
(
temps
=
[
u"TMP"
])
s
=
T
.
body
.
stats
s
=
T
.
stats
print
s
[
0
].
expr
.
name
print
s
[
0
].
expr
.
name
self
.
assert_
(
s
[
0
].
expr
.
name
.
__class__
is
TempName
)
self
.
assert_
(
s
[
0
].
expr
.
name
==
Naming
.
temp_prefix
+
u"1_TMP"
,
s
[
0
].
expr
.
name
)
self
.
assert_
(
s
[
1
].
rhs
.
name
.
__class__
is
TempName
)
self
.
assert_
(
s
[
1
].
rhs
.
name
==
Naming
.
temp_prefix
+
u"1_TMP"
)
self
.
assert_
(
s
[
0
].
expr
.
name
==
s
[
1
].
rhs
.
name
)
self
.
assert_
(
s
[
0
].
expr
.
name
!=
u"TMP"
)
self
.
assert_
(
s
[
0
].
expr
.
name
!=
u"TMP"
)
self
.
assert_
(
s
[
0
].
expr
.
name
!=
TempName
(
u"TMP"
))
self
.
assert_
(
s
[
0
].
expr
.
name
.
description
==
u"TMP"
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
import
unittest
import
unittest
...
...
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