]> granicus.if.org Git - python/commitdiff
More tweaks; re.py is nearly there...
authorGuido van Rossum <guido@python.org>
Tue, 15 Jul 1997 15:40:57 +0000 (15:40 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 15 Jul 1997 15:40:57 +0000 (15:40 +0000)
Lib/test/output/test_re
Lib/test/re_tests.py
Lib/test/test_re.py

index 7ba8cfa4af1ee8011662c4daf7c61a8c3d5c6df1..182ca054e3b903796d44df736b946695b2a2438c 100644 (file)
@@ -34,7 +34,6 @@ test_re
 ('a[b-d]e', 'ace', 0, 'found', 'ace')
 ('a[b-d]', 'aac', 0, 'found', 'ac')
 ('a[-b]', 'a-', 0, 'found', 'a-')
-=== Syntax error: ('a[-b]', 'a-', 0, 'found', 'a-')
 ('a[b-]', 'a-', 2)
 ('a[]b', '-', 2)
 ('a[', '-', 2)
@@ -43,16 +42,12 @@ test_re
 ('(abc', '-', 2)
 ('a]', 'a]', 0, 'found', 'a]')
 ('a[]]b', 'a]b', 0, 'found', 'a]b')
-=== Syntax error: ('a[]]b', 'a]b', 0, 'found', 'a]b')
 ('a[^bc]d', 'aed', 0, 'found', 'aed')
 ('a[^bc]d', 'abd', 1)
 ('a[^-b]c', 'adc', 0, 'found', 'adc')
-=== Syntax error: ('a[^-b]c', 'adc', 0, 'found', 'adc')
 ('a[^-b]c', 'a-c', 1)
-=== Syntax error: ('a[^-b]c', 'a-c', 1)
 ('a[^]b]c', 'a]c', 1)
 ('a[^]b]c', 'adc', 0, 'found', 'adc')
-=== Failed incorrectly ('a[^]b]c', 'adc', 0, 'found', 'adc')
 ('\\ba\\b', 'a-', 0, '"-"', '-')
 ('\\ba\\b', '-a', 0, '"-"', '-')
 ('\\ba\\b', '-a-', 0, '"-"', '-')
@@ -64,8 +59,7 @@ test_re
 ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
 === Syntax error: ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
 ('$b', 'b', 1)
-('a(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
-=== Syntax error: ('a(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
+('a\\(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
 ('a\\(*b', 'ab', 0, 'found', 'ab')
 ('a\\(*b', 'a((b', 0, 'found', 'a((b')
 ('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
@@ -113,7 +107,6 @@ test_re
 ('\\((.*), (.*)\\)', '(a, b)', 0, 'g2+"-"+g1', 'b-a')
 ('[k]', 'ab', 1)
 ('a[-]?c', 'ac', 0, 'found', 'ac')
-=== Syntax error: ('a[-]?c', 'ac', 0, 'found', 'ac')
 ('(abc)\\1', 'abcabc', 0, 'g1', 'abc')
 ('([a-c]*)\\1', 'abcabc', 0, 'g1', 'abc')
 ('^(.+)?B', 'AB', 0, 'g1', 'A')
index a43b4acc8d3ffbaee3886ee8c96c8fe025cd47f6..393e2b2c92deb3991792bbaa3eab12258be4f2c7 100755 (executable)
@@ -136,7 +136,7 @@ tests = [
 ('()ef', 'def', SUCCEED,
  'found+"-"+g1', 'ef-'),
 ('$b', 'b', FAIL),
-('a(b', 'a(b', SUCCEED,
+('a\\(b', 'a(b', SUCCEED,
  'found+"-"+g1', 'a(b-None'),
 ('a\\(*b', 'ab', SUCCEED,
  'found', 'ab'),
index 39d3df01aab082f95613849f65b5d1ea25edd1d2..cef14b0822905a7a29609721da9b73af8beaca50 100644 (file)
@@ -41,16 +41,15 @@ for t in tests:
                # Matched, as expected, so now we compute the
                # result string and compare it to our expected result.
                start, end = result.span(0)
-               vardict={'found': result.group(0)}
+               vardict={'found': result.group(0), 'groups': result.group()}
                for i in range(1, 100):
                    try:
                        gi = result.group(i)
                        # Special hack because else the string concat fails:
                        if gi is None: gi = "None"
                    except IndexError:
-                       break
-                   else:
-                       vardict['g%d' % i] = gi
+                       gi = "None"
+                   vardict['g%d' % i] = gi
                repl=eval(repl, vardict)
                if repl!=expected:
                    print '=== grouping error', t,