'Test matching nodes based on precedence relations.'

def test_rel_precedence(self):

    tree = ParentedTree.fromstring(u'(S    (NP    (NP    (PP    x))    (NP    (AP    x)))    (VP    (AP    (X    (PP    x))    (Y    (AP    x))))    (NP    (RC    (NP    (AP    x)))))')
    self.assertEqual(list(tgrep.tgrep_positions(u'*    .    X', [tree])), [[(0,), (0, 1), (0, 1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    .    Y', [tree])), [[(1, 0, 0), (1, 0, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    ..    X', [tree])), [[(0,), (0, 0), (0, 0, 0), (0, 1), (0, 1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    ..    Y', [tree])), [[(0,), (0, 0), (0, 0, 0), (0, 1), (0, 1, 0), (1, 0, 0), (1, 0, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    ,    X', [tree])), [[(1, 0, 1), (1, 0, 1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    ,    Y', [tree])), [[(2,), (2, 0), (2, 0, 0), (2, 0, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    ,,    X', [tree])), [[(1, 0, 1), (1, 0, 1, 0), (2,), (2, 0), (2, 0, 0), (2, 0, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    ,,    Y', [tree])), [[(2,), (2, 0), (2, 0, 0), (2, 0, 0, 0)]])
