'Test matching nodes based on dominance relations.'

def tests_rel_dominance(self):

    tree = ParentedTree.fromstring(u'(S    (A    (T    x))    (B    (N    x)))')
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <    T', [tree])), [[(0,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <    T    >    S', [tree])), [[(0,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !<    T', [tree])), [[(), (0, 0), (0, 0, 0), (1,), (1, 0), (1, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !<    T    >    S', [tree])), [[(1,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    >    A', [tree])), [[(0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    >    B', [tree])), [[(1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !>    B', [tree])), [[(), (0,), (0, 0), (0, 0, 0), (1,), (1, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !>    B    >>    S', [tree])), [[(0,), (0, 0), (1,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    >>    S', [tree])), [[(0,), (0, 0), (1,), (1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    >>,    S', [tree])), [[(0,), (0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u"*    >>'    S", [tree])), [[(1,), (1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <<    T', [tree])), [[(), (0,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u"*    <<'    T", [tree])), [[(0,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <<1    N', [tree])), [[(1,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !<<    T', [tree])), [[(0, 0), (0, 0, 0), (1,), (1, 0), (1, 0, 0)]])
    tree = ParentedTree.fromstring(u'(S    (A    (T    x))    (B    (T    x)    (N    x    )))')
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <:    T', [tree])), [[(0,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <    T', [tree])), [[(0,), (1,)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !<:    T', [tree])), [[(), (0, 0), (0, 0, 0), (1,), (1, 0), (1, 0, 0), (1, 1), (1, 1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !<:    T    >    S', [tree])), [[(1,)]])
    tree = ParentedTree.fromstring(u'(S    (T    (A    x)    (B    x))    (T    (C    x)))')
    self.assertEqual(list(tgrep.tgrep_positions(u'*    >:    T', [tree])), [[(1, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    !>:    T', [tree])), [[(), (0,), (0, 0), (0, 0, 0), (0, 1), (0, 1, 0), (1,), (1, 0, 0)]])
    tree = ParentedTree.fromstring(u'(S    (A    (B    (C    (D    (E    (T    x))))))    (A    (B    (C    (D    (E    (T    x)))    (N    x)))))')
    self.assertEqual(list(tgrep.tgrep_positions(u'*    <<:    T', [tree])), [[(0,), (0, 0), (0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0, 0), (1, 0, 0, 0), (1, 0, 0, 0, 0)]])
    self.assertEqual(list(tgrep.tgrep_positions(u'*    >>:    A', [tree])), [[(0, 0), (0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0), (1, 0), (1, 0, 0)]])
