Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
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
trs
Commits
a290533e
Commit
a290533e
authored
Jan 24, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of kompiler.org:trs
parents
99832583
c3511de6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
src/rules/negation.py
src/rules/negation.py
+0
-3
tests/test_leiden_oefenopgave.py
tests/test_leiden_oefenopgave.py
+19
-0
No files found.
src/rules/negation.py
View file @
a290533e
...
@@ -63,13 +63,10 @@ def negate_group(root, args):
...
@@ -63,13 +63,10 @@ def negate_group(root, args):
"""
"""
node
,
scope
=
args
node
,
scope
=
args
print
'negate_group:'
,
node
,
map
(
str
,
scope
)
# Negate each group
# Negate each group
for
i
,
n
in
enumerate
(
scope
):
for
i
,
n
in
enumerate
(
scope
):
scope
[
i
]
=
-
n
scope
[
i
]
=
-
n
print
nary_node
(
'+'
,
scope
)
return
nary_node
(
'+'
,
scope
)
return
nary_node
(
'+'
,
scope
)
...
...
tests/test_leiden_oefenopgave.py
View file @
a290533e
...
@@ -86,6 +86,25 @@ class TestLeidenOefenopgave(TestCase):
...
@@ -86,6 +86,25 @@ class TestLeidenOefenopgave(TestCase):
# FIXME: self.assertRewrite(['x * -1 + x * -1', '(-1 + -1)x', '-2x'])
# FIXME: self.assertRewrite(['x * -1 + x * -1', '(-1 + -1)x', '-2x'])
pass
pass
def
test_1_5
(
self
):
self
.
assertRewrite
([
'(2x + x)x'
,
'(2 + 1)xx'
,
'3xx'
,
'3 * x ^ (1 + 1)'
,
'3 * x ^ 2'
])
def
test_1_7
(
self
):
self
.
assertRewrite
([
'(4x + 5) * -(5 - 4x)'
,
'(4x + 5)(-5 - -4x)'
,
'(4x + 5)(-5 + 4x)'
,
'4x * -5 + 4x * 4x + 5 * -5 + 5 * 4x'
,
'-20x + 4x * 4x + 5 * -5 + 5 * 4x'
,
'-20x + 16xx + 5 * -5 + 5 * 4x'
,
'-20x + 16 * x ^ (1 + 1) + 5 * -5 + 5 * 4x'
,
'-20x + 16 * x ^ 2 + 5 * -5 + 5 * 4x'
,
'-20x + 16 * x ^ 2 - 25 + 5 * 4x'
,
'-20x + 16 * x ^ 2 - 25 + 20x'
,
'(-20 + 20)x + 16 * x ^ 2 - 25'
,
'0x + 16 * x ^ 2 - 25'
,])
# FIXME: '16x^2 - 25'])
def
test_2
(
self
):
def
test_2
(
self
):
pass
pass
...
...
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