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
8f84aef4
Commit
8f84aef4
authored
Jun 12, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a unit test that mysteriously failes validation...
parent
1f798cfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
src/validation.py
src/validation.py
+8
-2
tests/test_validation.py
tests/test_validation.py
+4
-0
No files found.
src/validation.py
View file @
8f84aef4
...
...
@@ -32,21 +32,27 @@ def validate(exp, result):
parser
.
set_root_node
(
exp
)
a
=
parser
.
rewrite_all
()
if
not
a
:
return
False
parser
.
set_root_node
(
result
)
b
=
parser
.
rewrite_all
()
if
not
a
or
not
a
.
equals
(
b
):
if
not
a
.
equals
(
b
):
return
False
# TODO: make sure cycles are avoided / eliminated using cycle detection.
def
traverse_preorder
(
node
,
result
):
#print 'node:', node, 'result:', result
if
node
.
equals
(
result
):
return
True
for
p
in
find_possibilities
(
node
):
# Clone the root node because it will be used in multiple
# substitutions
child
=
apply_suggestion
(
node
.
clone
(),
p
)
temp
=
node
.
clone
()
child
=
apply_suggestion
(
node
,
p
)
node
=
temp
if
traverse_preorder
(
child
,
result
):
return
True
...
...
tests/test_validation.py
View file @
8f84aef4
...
...
@@ -31,6 +31,10 @@ class TestValidation(TestCase):
def
test_intermediate_failure
(
self
):
self
.
assertFalse
(
validate
(
'3a + a + b + 2b'
,
'4a + 4b'
))
#def test_success(self):
# self.assertTrue(validate('x^2 + x - 2x^2 + 3x + 1',
# 'x^2 + 4x - 2x^2 + 1'))
#def test_indefinite_integral(self):
# self.assertTrue(validate('int_2^4 x^2', '4^3/3 - 2^3/3'))
...
...
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