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
a350c6f1
Commit
a350c6f1
authored
Jan 05, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged new tests with older changes.
parent
567e8f5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
line.py
line.py
+1
-1
tests/test_line.py
tests/test_line.py
+5
-5
No files found.
line.py
View file @
a350c6f1
...
@@ -98,7 +98,7 @@ def generate_line(root):
...
@@ -98,7 +98,7 @@ def generate_line(root):
child_pred
=
pred
(
child
)
child_pred
=
pred
(
child
)
if
child_pred
<
node_pred
or
\
if
child_pred
<
node_pred
or
\
(
child_pred
==
node_pred
and
s
!=
child
.
title
()):
(
child_pred
==
node_pred
and
op
!=
child
.
title
()):
exp
=
'('
+
exp
+
')'
exp
=
'('
+
exp
+
')'
# a * b -> ab
# a * b -> ab
...
...
tests/test_line.py
View file @
a350c6f1
...
@@ -24,14 +24,14 @@ class TestLine(unittest.TestCase):
...
@@ -24,14 +24,14 @@ class TestLine(unittest.TestCase):
self
.
assertEquals
(
generate_line
(
times
),
'(1 + 2) * (1 + 2)'
)
self
.
assertEquals
(
generate_line
(
times
),
'(1 + 2) * (1 + 2)'
)
def
test_parentheses_equal_precedence
(
self
):
def
test_parentheses_equal_precedence
(
self
):
l0
,
l1
,
l2
=
L
eaf
(
1
),
Leaf
(
2
),
Leaf
(
3
)
l0
,
l1
,
l2
=
L
(
1
),
L
(
2
),
L
(
3
)
plus
=
N
ode
(
'+'
,
l1
,
l2
)
plus
=
N
(
'+'
,
l1
,
l2
)
minus
=
N
ode
(
'-'
,
l0
,
plus
)
minus
=
N
(
'-'
,
l0
,
plus
)
self
.
assertEquals
(
generate_line
(
minus
),
'1 - (2 + 3)'
)
self
.
assertEquals
(
generate_line
(
minus
),
'1 - (2 + 3)'
)
def
test_parentheses_nary
(
self
):
def
test_parentheses_nary
(
self
):
l0
,
l1
,
l2
=
L
eaf
(
1
),
Leaf
(
2
),
Leaf
(
3
)
l0
,
l1
,
l2
=
L
(
1
),
L
(
2
),
L
(
3
)
plus
=
N
ode
(
'+'
,
Node
(
'+'
,
l0
,
l1
),
l2
)
plus
=
N
(
'+'
,
N
(
'+'
,
l0
,
l1
),
l2
)
self
.
assertEquals
(
generate_line
(
plus
),
'1 + 2 + 3'
)
self
.
assertEquals
(
generate_line
(
plus
),
'1 + 2 + 3'
)
def
test_function
(
self
):
def
test_function
(
self
):
...
...
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