Ejemplo n.º 1
0
class TestNthChildWithExtraChecks(SelectorTest):
    description = 'select two children of FORMAL_PARAM_STD_DECL at index 2 '
    selector = Type('FORMAL_PARAM_STD_DECL')[2]

    def test(self):
        nodes = self.walk(self.selector)
        self.assertNodes(nodes, 2)
        self.assertEqual(nodes[0].type, tokens.IDENT)
        self.assertEqual(nodes[1].type, tokens.IDENT)
        self.assertEqual(nodes[0].text, 'x')
        self.assertEqual(nodes[1].text, 'y')
Ejemplo n.º 2
0
class TestSimpleSiblings(SelectorTest):
    description = 'select three IDENT nodes that are adjacent siblings of a MODIFIER_LIST'
    selector = Type('MODIFIER_LIST') + Type('IDENT')
    test = SelectorTest.make(3)
Ejemplo n.º 3
0
class TestDirectChildren(SelectorTest):
    description = 'select two TYPE nodes that are children of a VAR_DECLARATION node'
    selector = Type('VAR_DECLARATION') > Type('TYPE')
    test = SelectorTest.make(2)
Ejemplo n.º 4
0
class TestIdentWithText(SelectorTest):
    description = 'select two IDENT nodes with text "foo"'
    selector = Type('IDENT', 'foo')
    test = SelectorTest.make(2)
Ejemplo n.º 5
0
class TestIdentChildOfClass(SelectorTest):
    description = 'select one IDENT node that is a child of a CLASS node'
    selector = Type('CLASS') > Type('IDENT')
    test = SelectorTest.make(1)
Ejemplo n.º 6
0
class TestSimpleAnySibling(SelectorTest):
    description = 'select three FORMAL_PARAM_LIST nodes that are non-adjacent siblings of a MODIFIER_LIST'
    selector = Type('MODIFIER_LIST') / Type('FORMAL_PARAM_LIST')
    test = SelectorTest.make(2)