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
fe4e092c
Commit
fe4e092c
authored
Sep 13, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Division by negated multiplication is now printed correctly by line printer.
parent
e17779f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
line.py
line.py
+2
-2
tests/test_line.py
tests/test_line.py
+10
-0
No files found.
line.py
View file @
fe4e092c
...
...
@@ -247,14 +247,14 @@ def generate_line(root):
lparens
=
is_right_assoc
(
left
.
title
())
or
is_right_assoc
(
op
)
if
rpred
<
op_pred
:
rparens
=
not
unary_right
rparens
=
not
unary_right
or
len
(
right
[
0
])
>
1
elif
rpred
==
op_pred
and
len
(
right
)
>
1
:
if
right
.
title
()
==
op
:
rparens
=
not
is_right_assoc
(
op
)
elif
is_left_assoc
(
right
.
title
()):
rparens
=
True
# Check if multiplication sig is necessary
# Check if multiplication sig
n
is necessary
if
op
==
'*'
and
not
unary_right
:
sep
=
mult_sign
(
left
,
right
,
lparens
,
rparens
)
...
...
tests/test_line.py
View file @
fe4e092c
...
...
@@ -338,3 +338,13 @@ class TestLine(unittest.TestCase):
def
addbrackets
(
self
):
self
[
0
]
=
N
(
'[]'
,
self
[
0
])
root
.
preprocess_str_exp
=
new
.
instancemethod
(
addbrackets
,
root
)
self
.
assertEquals
(
generate_line
(
root
),
'-[1]'
)
def
test_division_by_multiplication
(
self
):
root
=
N
(
'/'
,
L
(
1
),
N
(
'*'
,
L
(
'a'
),
L
(
'b'
)))
self
.
assertEquals
(
generate_line
(
root
),
'1 / (ab)'
)
root
=
N
(
'/'
,
L
(
1
),
-
N
(
'*'
,
L
(
'a'
),
L
(
'b'
)))
self
.
assertEquals
(
generate_line
(
root
),
'1 / (-ab)'
)
root
=
N
(
'/'
,
L
(
1
),
N
(
'*'
,
-
L
(
'a'
),
L
(
'b'
)))
self
.
assertEquals
(
generate_line
(
root
),
'1 / ((-a)b)'
)
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