Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
graph_drawing
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
graph_drawing
Commits
ade1a950
Commit
ade1a950
authored
Apr 09, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified parentheses when handling with negation due to precedence change.
parent
ea4270eb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
line.py
line.py
+1
-1
tests/test_line.py
tests/test_line.py
+3
-3
No files found.
line.py
View file @
ade1a950
...
...
@@ -146,7 +146,7 @@ def generate_line(root):
# (-a) * b
# a * -b
# (-a) / b
if
(
node_pred
>
NEG_PRED
and
not
i
)
:
if
node_pred
>
NEG_PRED
:
exp
=
'('
+
exp
+
')'
elif
child_pred
<
node_pred
:
exp
=
'('
+
exp
+
')'
...
...
tests/test_line.py
View file @
ade1a950
...
...
@@ -77,7 +77,7 @@ class TestLine(unittest.TestCase):
def
test_multiplication_identifiers
(
self
):
a
,
b
=
L
(
'a'
),
L
(
'b'
)
self
.
assertEquals
(
generate_line
(
N
(
'*'
,
a
,
b
)),
'ab'
)
self
.
assertEquals
(
generate_line
(
N
(
'*'
,
a
,
-
b
)),
'a
* -b
'
)
self
.
assertEquals
(
generate_line
(
N
(
'*'
,
a
,
-
b
)),
'a
(-b)
'
)
def
test_multiplication_constant_identifier
(
self
):
l0
,
a
=
L
(
2
),
L
(
'a'
)
...
...
@@ -219,7 +219,7 @@ class TestLine(unittest.TestCase):
self
.
assertEquals
(
generate_line
(
neg
),
'-4a'
)
neg
=
N
(
'*'
,
L
(
4
),
-
L
(
'a'
))
self
.
assertEquals
(
generate_line
(
neg
),
'4
* -a
'
)
self
.
assertEquals
(
generate_line
(
neg
),
'4
(-a)
'
)
neg
=
-
N
(
'*'
,
L
(
4
),
L
(
5
))
self
.
assertEquals
(
generate_line
(
neg
),
'-4 * 5'
)
...
...
@@ -234,7 +234,7 @@ class TestLine(unittest.TestCase):
self
.
assertEquals
(
generate_line
(
plus
),
'a / b - c / d'
)
mul
=
N
(
'*'
,
N
(
'+'
,
L
(
'a'
),
L
(
'b'
)),
-
N
(
'+'
,
L
(
'c'
),
L
(
'd'
)))
self
.
assertEquals
(
generate_line
(
mul
),
'(a + b)
* -(c + d
)'
)
self
.
assertEquals
(
generate_line
(
mul
),
'(a + b)
(-(c + d)
)'
)
def
test_double_negation
(
self
):
neg
=
--
L
(
1
)
...
...
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