[Python-checkins] python/dist/src/Lib/test test_sre.py,1.38,1.39

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Mon, 14 Apr 2003 11:00:07 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv12812/Lib/test

Modified Files:
	test_sre.py 
Log Message:
SF patch #720991 by Gary Herron:
A small fix for bug #545855 and Greg Chapman's
addition of op code SRE_OP_MIN_REPEAT_ONE for
eliminating recursion on simple uses of pattern '*?' on a
long string.


Index: test_sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** test_sre.py	6 Nov 2002 14:06:52 -0000	1.38
--- test_sre.py	14 Apr 2003 17:59:33 -0000	1.39
***************
*** 84,87 ****
--- 84,100 ----
  test(r"""sre.match(r'(?P<a>a)(?P<b>b)?b','ab').lastgroup""", 'a')
  
+ # bug 545855 -- This pattern failed to cause a compile error as it
+ # should, instead provoking a TypeError.
+ test(r"""sre.compile('foo[a-')""", None, sre.error)
+ 
+ # bugs 418626 at al. -- Testing Greg Chapman's addition of op code
+ # SRE_OP_MIN_REPEAT_ONE for eliminating recursion on simple uses of
+ # pattern '*?' on a long string.
+ test(r"""sre.match('.*?c', 10000*'ab'+'cd').end(0)""", 20001)
+ test(r"""sre.match('.*?cd', 5000*'ab'+'c'+5000*'ab'+'cde').end(0)""", 20003)
+ test(r"""sre.match('.*?cd', 20000*'abc'+'de').end(0)""", 60001)
+ # non-simple '*?' still recurses and hits the recursion limit
+ test(r"""sre.search('(a|b)*?c', 10000*'ab'+'cd').end(0)""", None, RuntimeError)
+ 
  if verbose:
      print 'Running tests on sre.sub'