Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
8f84aef4
Commit
8f84aef4
authored
12 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added a unit test that mysteriously failes validation...
parent
1f798cfb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/validation.py
+8
-2
8 additions, 2 deletions
src/validation.py
tests/test_validation.py
+4
-0
4 additions, 0 deletions
tests/test_validation.py
with
12 additions
and
2 deletions
src/validation.py
+
8
−
2
View file @
8f84aef4
...
@@ -32,21 +32,27 @@ def validate(exp, result):
...
@@ -32,21 +32,27 @@ def validate(exp, result):
parser
.
set_root_node
(
exp
)
parser
.
set_root_node
(
exp
)
a
=
parser
.
rewrite_all
()
a
=
parser
.
rewrite_all
()
if
not
a
:
return
False
parser
.
set_root_node
(
result
)
parser
.
set_root_node
(
result
)
b
=
parser
.
rewrite_all
()
b
=
parser
.
rewrite_all
()
if
not
a
or
not
a
.
equals
(
b
):
if
not
a
.
equals
(
b
):
return
False
return
False
# TODO: make sure cycles are avoided / eliminated using cycle detection.
# TODO: make sure cycles are avoided / eliminated using cycle detection.
def
traverse_preorder
(
node
,
result
):
def
traverse_preorder
(
node
,
result
):
#print 'node:', node, 'result:', result
if
node
.
equals
(
result
):
if
node
.
equals
(
result
):
return
True
return
True
for
p
in
find_possibilities
(
node
):
for
p
in
find_possibilities
(
node
):
# Clone the root node because it will be used in multiple
# Clone the root node because it will be used in multiple
# substitutions
# substitutions
child
=
apply_suggestion
(
node
.
clone
(),
p
)
temp
=
node
.
clone
()
child
=
apply_suggestion
(
node
,
p
)
node
=
temp
if
traverse_preorder
(
child
,
result
):
if
traverse_preorder
(
child
,
result
):
return
True
return
True
...
...
This diff is collapsed.
Click to expand it.
tests/test_validation.py
+
4
−
0
View file @
8f84aef4
...
@@ -31,6 +31,10 @@ class TestValidation(TestCase):
...
@@ -31,6 +31,10 @@ class TestValidation(TestCase):
def
test_intermediate_failure
(
self
):
def
test_intermediate_failure
(
self
):
self
.
assertFalse
(
validate
(
'
3a + a + b + 2b
'
,
'
4a + 4b
'
))
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):
#def test_indefinite_integral(self):
# self.assertTrue(validate('int_2^4 x^2', '4^3/3 - 2^3/3'))
# self.assertTrue(validate('int_2^4 x^2', '4^3/3 - 2^3/3'))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment