Exemple #1
0
 def test_match2(self):
     # This regular expression is known to kill the python re module
     # because it exploits the fact that the implementation has exponential
     # worst case complexity.
     # Instead, this implementation has polinomial worst case complexity,
     # and therefore this test should finish in a reasonable time.
     N = 100
     a = refo.Literal("a")
     strg = "a" * N
     regexptn = refo.Question(a) * N + a * N
     m = refomatch(regexptn, strg)
     self.assertNotEqual(m, None)
Exemple #2
0
 def test_match_path(self):
     seq = [[1, 2],     # x and y
            [1],        # x
            [1, 2, 3],  # x, y and z
            [1, 2],     # x and y
            [2, 3],     # y and z
            [0, 4, 5],
            []]
     regexptn = refo.Star(self.y) + refo.Plus(self.x + self.z)
     m = refomatch(regexptn, seq, keep_path=True)
     self.assert_(isinstance(m, Match))
     path = m.get_path()
     self.assertEqual([4, 1, 9, 1, 9], path)
Exemple #3
0
 def test_match1(self):
     regexptn = self.b + self.b + self.a + self.a + self.b
     strregex = re.compile("bbaab")
     m = refomatch(regexptn, self.seq)
     strm = strregex.match(self.string)
     self._eq_span_n_stuff(m, strm)