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
5f556a4e
Commit
5f556a4e
authored
Apr 23, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added function to get the index of a node in a Scope object.
parent
2f20f14d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
src/node.py
src/node.py
+3
-0
tests/test_node.py
tests/test_node.py
+5
-0
No files found.
src/node.py
View file @
5f556a4e
...
@@ -572,6 +572,9 @@ class Scope(object):
...
@@ -572,6 +572,9 @@ class Scope(object):
def __repr__(self):
def __repr__(self):
return '
<
Scope
of
"%s"
>
' % repr(self.node)
return '
<
Scope
of
"%s"
>
' % repr(self.node)
def index(self, node):
return self.nodes.index(node)
def remove(self, node, **kwargs):
def remove(self, node, **kwargs):
try:
try:
i = self.nodes.index(node)
i = self.nodes.index(node)
...
...
tests/test_node.py
View file @
5f556a4e
...
@@ -110,6 +110,11 @@ class TestNode(RulesTestCase):
...
@@ -110,6 +110,11 @@ class TestNode(RulesTestCase):
root
,
a
,
b
,
cd
=
tree
(
'a * b * -cd, a, b, -cd'
)
root
,
a
,
b
,
cd
=
tree
(
'a * b * -cd, a, b, -cd'
)
self
.
assertEqual
(
get_scope
(
root
),
[
a
,
b
,
cd
])
self
.
assertEqual
(
get_scope
(
root
),
[
a
,
b
,
cd
])
def
test_get_scope_index
(
self
):
self
.
assertEqual
(
self
.
scope
.
index
(
self
.
a
),
0
)
self
.
assertEqual
(
self
.
scope
.
index
(
self
.
b
),
1
)
self
.
assertEqual
(
self
.
scope
.
index
(
self
.
cd
),
2
)
def
test_equals_node_leaf
(
self
):
def
test_equals_node_leaf
(
self
):
a
,
b
=
plus
=
tree
(
'a + b'
)
a
,
b
=
plus
=
tree
(
'a + b'
)
...
...
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