diff options
Diffstat (limited to 'src/regexp/syntax/simplify_test.go')
| -rw-r--r-- | src/regexp/syntax/simplify_test.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/regexp/syntax/simplify_test.go b/src/regexp/syntax/simplify_test.go index 9877db3d0a..6d06f99c1b 100644 --- a/src/regexp/syntax/simplify_test.go +++ b/src/regexp/syntax/simplify_test.go @@ -13,7 +13,7 @@ var simplifyTests = []struct { // Already-simple constructs {`a`, `a`}, {`ab`, `ab`}, - {`a|b`, `[a-b]`}, + {`a|b`, `[ab]`}, {`ab|cd`, `ab|cd`}, {`(ab)*`, `(ab)*`}, {`(ab)+`, `(ab)+`}, @@ -40,16 +40,16 @@ var simplifyTests = []struct { // Perl character classes {`\d`, `[0-9]`}, - {`\s`, `[\t-\n\f-\r ]`}, + {`\s`, `[\t\n\f\r ]`}, {`\w`, `[0-9A-Z_a-z]`}, {`\D`, `[^0-9]`}, - {`\S`, `[^\t-\n\f-\r ]`}, + {`\S`, `[^\t\n\f\r ]`}, {`\W`, `[^0-9A-Z_a-z]`}, {`[\d]`, `[0-9]`}, - {`[\s]`, `[\t-\n\f-\r ]`}, + {`[\s]`, `[\t\n\f\r ]`}, {`[\w]`, `[0-9A-Z_a-z]`}, {`[\D]`, `[^0-9]`}, - {`[\S]`, `[^\t-\n\f-\r ]`}, + {`[\S]`, `[^\t\n\f\r ]`}, {`[\W]`, `[^0-9A-Z_a-z]`}, // Posix repetitions @@ -82,7 +82,8 @@ var simplifyTests = []struct { {`a{0}`, `(?:)`}, // Character class simplification - {`[ab]`, `[a-b]`}, + {`[ab]`, `[ab]`}, + {`[abc]`, `[a-c]`}, {`[a-za-za-z]`, `[a-z]`}, {`[A-Za-zA-Za-z]`, `[A-Za-z]`}, {`[ABCDEFGH]`, `[A-H]`}, @@ -120,7 +121,8 @@ var simplifyTests = []struct { // interesting than they might otherwise be. String inserts // explicit (?:) in place of non-parenthesized empty strings, // to make them easier to spot for other parsers. - {`(a|b|)`, `([a-b]|(?:))`}, + {`(a|b|c|)`, `([a-c]|(?:))`}, + {`(a|b|)`, `([ab]|(?:))`}, {`(|)`, `()`}, {`a()`, `a()`}, {`(()|())`, `(()|())`}, |
