Commit 5f556a4e authored by Taddeus Kroes's avatar Taddeus Kroes

Added function to get the index of a node in a Scope object.

parent 2f20f14d
......@@ -572,6 +572,9 @@ class Scope(object):
def __repr__(self):
return '<Scope of "%s">' % repr(self.node)
def index(self, node):
return self.nodes.index(node)
def remove(self, node, **kwargs):
try:
i = self.nodes.index(node)
......
......@@ -110,6 +110,11 @@ class TestNode(RulesTestCase):
root, a, b, cd = tree('a * b * -cd, 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):
a, b = plus = tree('a + b')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment