diff options
author | Russ Cox <rsc@golang.org> | 2014-10-20 12:16:46 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-10-20 12:16:46 -0400 |
commit | b5da7b79e14bee37e91b27a2c9b8223f122d97c0 (patch) | |
tree | 06b8b88ff4996a80dab8eb0602b0f498edab4829 | |
parent | 53e3043abdfafde7ef47d40aa8031aa4206d439e (diff) | |
download | go-b5da7b79e14bee37e91b27a2c9b8223f122d97c0.tar.gz |
regexp: fix TestOnePassCutoff
The stack blowout can no longer happen,
but we can still test that too-complex regexps
are rejected.
Replacement for CL 162770043.
LGTM=iant, r
R=r, iant
CC=bradfitz, golang-codereviews
https://codereview.appspot.com/162860043
-rw-r--r-- | src/regexp/all_test.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/regexp/all_test.go b/src/regexp/all_test.go index 5fadb67c0..01ea3742a 100644 --- a/src/regexp/all_test.go +++ b/src/regexp/all_test.go @@ -6,6 +6,7 @@ package regexp import ( "reflect" + "regexp/syntax" "strings" "testing" ) @@ -473,12 +474,19 @@ func TestSplit(t *testing.T) { } } -// This ran out of stack before issue 7608 was fixed. +// Check that one-pass cutoff does trigger. func TestOnePassCutoff(t *testing.T) { - if testing.Short() { - t.Skip("Skipping in short mode") + re, err := syntax.Parse(`^x{1,1000}y{1,1000}$`, syntax.Perl) + if err != nil { + t.Fatalf("parse: %v", err) + } + p, err := syntax.Compile(re.Simplify()) + if err != nil { + t.Fatalf("compile: %v", err) + } + if compileOnePass(p) != notOnePass { + t.Fatalf("makeOnePass succeeded; wanted notOnePass") } - MustCompile(`^(?:x{1,1000}){1,1000}$`) } func BenchmarkLiteral(b *testing.B) { |