コード例 #1
0
 def test_empty_minuntil(self):
     r_code, r = get_code_and_re(r'(a?)+?y')
     #assert not r.match('z') -- CPython bug (at least 2.5) eats all memory
     res = self.match(r_code, 'z')
     assert not res
     #
     r_code, r = get_code_and_re(r'(a?){4,6}?y')
     assert not r.match('z')
     res = self.match(r_code, 'z')
     assert not res
     #
     r_code, r = get_code_and_re(r'(a?)*?y')
     #assert not r.match('z') -- CPython bug (at least 2.5) eats all memory
     res = self.match(r_code, 'z')
     assert not res
コード例 #2
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_empty_minuntil(self):
     r_code, r = get_code_and_re(r'(a?)+?y')
     #assert not r.match('z') -- CPython bug (at least 2.5) eats all memory
     res = rsre_core.match(r_code, 'z')
     assert not res
     #
     r_code, r = get_code_and_re(r'(a?){4,6}?y')
     assert not r.match('z')
     res = rsre_core.match(r_code, 'z')
     assert not res
     #
     r_code, r = get_code_and_re(r'(a?)*?y')
     #assert not r.match('z') -- CPython bug (at least 2.5) eats all memory
     res = rsre_core.match(r_code, 'z')
     assert not res
コード例 #3
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_empty_maxuntil(self):
     r_code, r = get_code_and_re(r'(a?)+y')
     assert r.match('y')
     res = rsre_core.match(r_code, 'y')
     assert res
     #
     r_code, r = get_code_and_re(r'(a?){4,6}y')
     assert r.match('y')
     res = rsre_core.match(r_code, 'y')
     assert res
     #
     r_code, r = get_code_and_re(r'(a?)*y')
     assert r.match('y')
     res = rsre_core.match(r_code, 'y')
     assert res
コード例 #4
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_min_until_3_5(self):
     r_code2, r = get_code_and_re(r'<abc>(?:xy){3,5}?xy</abc>')
     for i in range(8):
         s = '<abc>' + 'xy'*i + '</abc>defdefdefdefdef'
         assert (r.match(s) is not None) is (3 <= i-1 <= 5)
         res = rsre_core.match(r_code2, s)
         assert (res is not None) is (3 <= i-1 <= 5)
コード例 #5
0
 def test_min_until_3_5(self):
     r_code2, r = get_code_and_re(r'<abc>(?:xy){3,5}?xy</abc>')
     for i in range(8):
         s = '<abc>' + 'xy' * i + '</abc>defdefdefdefdef'
         assert (r.match(s) is not None) is (3 <= i - 1 <= 5)
         res = self.match(r_code2, s)
         assert (res is not None) is (3 <= i - 1 <= 5)
コード例 #6
0
 def test_minuntil_bug(self):
     r_code9, r9 = get_code_and_re(r'((x|yz)+?(y)??c)*')
     match = r9.match('xycxyzxc')
     assert match.span(2) == (6, 7)
     #assert match.span(3) == (1, 2) --- bug of CPython
     res = rsre_core.match(r_code9, 'xycxyzxc')
     assert (res.get_mark(2), res.get_mark(3)) == (6, 7)
     assert (res.get_mark(4), res.get_mark(5)) == (1, 2)
コード例 #7
0
 def test_minuntil_lastmark_restore(self):
     r_code9, r9 = get_code_and_re(r'(x|yz)+?(y)??c')
     match = r9.match('xyzxc')
     assert match.span(1) == (3, 4)
     assert match.span(2) == (-1, -1)
     res = rsre_core.match(r_code9, 'xyzxc')
     assert (res.get_mark(0), res.get_mark(1)) == (3, 4)
     assert (res.get_mark(2), res.get_mark(3)) == (-1, -1)
コード例 #8
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_minuntil_bug(self):
     r_code9, r9 = get_code_and_re(r'((x|yz)+?(y)??c)*')
     match = r9.match('xycxyzxc')
     assert match.span(2) == (6, 7)
     #assert match.span(3) == (1, 2) --- bug of CPython
     res = rsre_core.match(r_code9, 'xycxyzxc')
     assert (res.get_mark(2), res.get_mark(3)) == (6, 7)
     assert (res.get_mark(4), res.get_mark(5)) == (1, 2)
コード例 #9
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_minuntil_lastmark_restore(self):
     r_code9, r9 = get_code_and_re(r'(x|yz)+?(y)??c')
     match = r9.match('xyzxc')
     assert match.span(1) == (3, 4)
     assert match.span(2) == (-1, -1)
     res = rsre_core.match(r_code9, 'xyzxc')
     assert (res.get_mark(0), res.get_mark(1)) == (3, 4)
     assert (res.get_mark(2), res.get_mark(3)) == (-1, -1)
コード例 #10
0
 def test_minuntil_bug(self):
     r_code9, r9 = get_code_and_re(r'((x|yz)+?(y)??c)*')
     m = r9.match('xycxyzxc')
     assert m.span(2) == (6, 7)
     #assert self.match.span(3) == (1, 2) --- bug of CPython
     res = self.match(r_code9, 'xycxyzxc')
     P = self.P
     assert (res.get_mark(2), res.get_mark(3)) == (P(6), P(7))
     assert (res.get_mark(4), res.get_mark(5)) == (P(1), P(2))
コード例 #11
0
 def test_minuntil_lastmark_restore(self):
     r_code9, r9 = get_code_and_re(r'(x|yz)+?(y)??c')
     m = r9.match('xyzxc')
     assert m.span(1) == (3, 4)
     assert m.span(2) == (-1, -1)
     res = self.match(r_code9, 'xyzxc')
     P = self.P
     assert (res.get_mark(0), res.get_mark(1)) == (P(3), P(4))
     assert (res.get_mark(2), res.get_mark(3)) == (-1, -1)
コード例 #12
0
 def test_empty_maxuntil(self):
     r_code, r = get_code_and_re(r'(a?)+y')
     assert r.match('y')
     assert r.match('aaayaaay').span() == (0, 4)
     res = rsre_core.match(r_code, 'y')
     assert res
     res = rsre_core.match(r_code, 'aaayaaay')
     assert res and res.span() == (0, 4)
     #
     r_code, r = get_code_and_re(r'(a?){4,6}y')
     assert r.match('y')
     res = rsre_core.match(r_code, 'y')
     assert res
     #
     r_code, r = get_code_and_re(r'(a?)*y')
     assert r.match('y')
     res = rsre_core.match(r_code, 'y')
     assert res
コード例 #13
0
 def test_empty_maxuntil_2(self):
     try:
         r_code, r = get_code_and_re(r'X(.*?)+X')
     except re.error as e:
         py.test.skip("older version of the stdlib: %s" % (e,))
     assert r.match('XfooXbarX').span() == (0, 5)
     assert r.match('XfooXbarX').span(1) == (4, 4)
     res = rsre_core.match(r_code, 'XfooXbarX')
     assert res.span() == (0, 5)
     assert res.span(1) == (4, 4)
コード例 #14
0
 def test_group_branch_repeat_complex_case(self):
     r_code8, r8 = get_code_and_re(r'<abc>((a)|(b))*</abc>')
     match = r8.match('<abc>ab</abc>')
     assert match.span(1) == (6, 7)
     assert match.span(3) == (6, 7)
     assert match.span(2) == (5, 6)
     res = rsre_core.match(r_code8, '<abc>ab</abc>')
     assert (res.get_mark(0), res.get_mark(1)) == (6, 7)
     assert (res.get_mark(4), res.get_mark(5)) == (6, 7)
     assert (res.get_mark(2), res.get_mark(3)) == (5, 6)
コード例 #15
0
 def test_group_7(self):
     r_code7, r7 = get_code_and_re(r'<abc>((a)?(b))*</abc>')
     match = r7.match('<abc>bbbabbbb</abc>')
     assert match.span(1) == (12, 13)
     assert match.span(3) == (12, 13)
     assert match.span(2) == (8, 9)
     res = rsre_core.match(r_code7, '<abc>bbbabbbb</abc>')
     assert (res.get_mark(0), res.get_mark(1)) == (12, 13)
     assert (res.get_mark(4), res.get_mark(5)) == (12, 13)
     assert (res.get_mark(2), res.get_mark(3)) == (8, 9)
コード例 #16
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_group_branch_repeat_complex_case(self):
     r_code8, r8 = get_code_and_re(r'<abc>((a)|(b))*</abc>')
     match = r8.match('<abc>ab</abc>')
     assert match.span(1) == (6, 7)
     assert match.span(3) == (6, 7)
     assert match.span(2) == (5, 6)
     res = rsre_core.match(r_code8, '<abc>ab</abc>')
     assert (res.get_mark(0), res.get_mark(1)) == (6, 7)
     assert (res.get_mark(4), res.get_mark(5)) == (6, 7)
     assert (res.get_mark(2), res.get_mark(3)) == (5, 6)
コード例 #17
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_group_7(self):
     r_code7, r7 = get_code_and_re(r'<abc>((a)?(b))*</abc>')
     match = r7.match('<abc>bbbabbbb</abc>')
     assert match.span(1) == (12, 13)
     assert match.span(3) == (12, 13)
     assert match.span(2) == (8, 9)
     res = rsre_core.match(r_code7, '<abc>bbbabbbb</abc>')
     assert (res.get_mark(0), res.get_mark(1)) == (12, 13)
     assert (res.get_mark(4), res.get_mark(5)) == (12, 13)
     assert (res.get_mark(2), res.get_mark(3)) == (8, 9)
コード例 #18
0
 def test_group_branch_repeat_complex_case(self):
     r_code8, r8 = get_code_and_re(r'<abc>((a)|(b))*</abc>')
     m = r8.match('<abc>ab</abc>')
     assert m.span(1) == (6, 7)
     assert m.span(3) == (6, 7)
     assert m.span(2) == (5, 6)
     res = self.match(r_code8, '<abc>ab</abc>')
     P = self.P
     assert (res.get_mark(0), res.get_mark(1)) == (P(6), P(7))
     assert (res.get_mark(4), res.get_mark(5)) == (P(6), P(7))
     assert (res.get_mark(2), res.get_mark(3)) == (P(5), P(6))
コード例 #19
0
 def test_group_7(self):
     r_code7, r7 = get_code_and_re(r'<abc>((a)?(b))*</abc>')
     m = r7.match('<abc>bbbabbbb</abc>')
     assert m.span(1) == (12, 13)
     assert m.span(3) == (12, 13)
     assert m.span(2) == (8, 9)
     res = self.match(r_code7, '<abc>bbbabbbb</abc>')
     P = self.P
     assert (res.get_mark(0), res.get_mark(1)) == (P(12), P(13))
     assert (res.get_mark(4), res.get_mark(5)) == (P(12), P(13))
     assert (res.get_mark(2), res.get_mark(3)) == (P(8), P(9))
コード例 #20
0
ファイル: test_search.py プロジェクト: charred/pypy
 def test_empty_search(self):
     r_code, r = get_code_and_re(r'')
     for j in range(-2, 6):
         for i in range(-2, 6):
             match = r.search('abc', i, j)
             res = rsre_core.search(r_code, 'abc', i, j)
             jk = min(max(j, 0), 3)
             ik = min(max(i, 0), 3)
             if ik <= jk:
                 assert match is not None
                 assert match.span() == (ik, ik)
                 assert res is not None
                 assert res.match_start == ik and res.match_end == ik
             else:
                 assert match is None
                 assert res is None
コード例 #21
0
 def test_empty_search(self):
     r_code, r = get_code_and_re(r'')
     for j in range(-2, 6):
         for i in range(-2, 6):
             match = r.search('abc', i, j)
             res = rsre_core.search(r_code, 'abc', i, j)
             jk = min(max(j, 0), 3)
             ik = min(max(i, 0), 3)
             if ik <= jk:
                 assert match is not None
                 assert match.span() == (ik, ik)
                 assert res is not None
                 assert res.match_start == ik and res.match_end == ik
             else:
                 assert match is None
                 assert res is None
コード例 #22
0
 def test_empty_maxuntil_2(self):
     try:
         r_code, r = get_code_and_re(r'X(.*?)+X')
     except re.error, e:
         py.test.skip("older version of the stdlib: %s" % (e,))