[Python-checkins] CVS: python/dist/src/Lib/test test_sre.py,1.30,1.31
Fredrik Lundh
effbot@users.sourceforge.net
Sun, 21 Oct 2001 11:04:13 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30794/Lib/test
Modified Files:
test_sre.py
Log Message:
sre.Scanner fixes (from Greg Chapman). also added a Scanner sanity
check to the test suite.
added a few missing exception checks in the _sre module
Index: test_sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** test_sre.py 2001/10/18 19:30:16 1.30
--- test_sre.py 2001/10/21 18:04:11 1.31
***************
*** 225,228 ****
--- 225,248 ----
if verbose:
+ print 'Running tests on sre.Scanner'
+
+ def s_ident(scanner, token): return token
+ def s_operator(scanner, token): return "op%s" % token
+ def s_float(scanner, token): return float(token)
+ def s_int(scanner, token): return int(token)
+
+ scanner = sre.Scanner([
+ (r"[a-zA-Z_]\w*", s_ident),
+ (r"\d+\.\d*", s_float),
+ (r"\d+", s_int),
+ (r"=|\+|-|\*|/", s_operator),
+ (r"\s+", None),
+ ])
+
+ # sanity check
+ test('scanner.scan("sum = 3*foo + 312.50 + bar")',
+ (['sum', 'op=', 3, 'op*', 'foo', 'op+', 312.5, 'op+', 'bar'], ''))
+
+ if verbose:
print 'Pickling a SRE_Pattern instance'