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
031e326f
Commit
031e326f
authored
Feb 16, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added equality chck and negation take-over to Scope object.
parent
f5d48c99
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
src/node.py
src/node.py
+5
-1
tests/test_node.py
tests/test_node.py
+5
-0
No files found.
src/node.py
View file @
031e326f
...
@@ -354,6 +354,10 @@ class Scope(object):
...
@@ -354,6 +354,10 @@ class Scope(object):
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
nodes
)
return
iter
(
self
.
nodes
)
def
__eq__
(
self
,
other
):
return
isinstance
(
other
,
Scope
)
and
self
.
node
==
other
.
node
\
and
self
.
nodes
==
other
.
node
def
remove
(
self
,
node
,
replacement
=
None
):
def
remove
(
self
,
node
,
replacement
=
None
):
if
node
.
is_leaf
:
if
node
.
is_leaf
:
node_cmp
=
hash
(
node
)
node_cmp
=
hash
(
node
)
...
@@ -381,7 +385,7 @@ class Scope(object):
...
@@ -381,7 +385,7 @@ class Scope(object):
self
.
remove
(
node
,
replacement
=
replacement
)
self
.
remove
(
node
,
replacement
=
replacement
)
def
as_nary_node
(
self
):
def
as_nary_node
(
self
):
return
nary_node
(
self
.
node
.
value
,
self
.
nodes
)
return
nary_node
(
self
.
node
.
value
,
self
.
nodes
)
.
negate
(
self
.
node
.
negated
)
def
nary_node
(
operator
,
scope
):
def
nary_node
(
operator
,
scope
):
...
...
tests/test_node.py
View file @
031e326f
...
@@ -193,3 +193,8 @@ class TestNode(RulesTestCase):
...
@@ -193,3 +193,8 @@ class TestNode(RulesTestCase):
def
test_scope_as_nary_node
(
self
):
def
test_scope_as_nary_node
(
self
):
self
.
assertEqualNodes
(
self
.
scope
.
as_nary_node
(),
self
.
n
)
self
.
assertEqualNodes
(
self
.
scope
.
as_nary_node
(),
self
.
n
)
def
test_scope_as_nary_node_negated
(
self
):
n
=
tree
(
'-(a + b)'
)
self
.
assertEqualNodes
(
Scope
(
n
).
as_nary_node
(),
n
)
self
.
assertEqualNodes
(
Scope
(
-
n
).
as_nary_node
(),
-
n
)
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