From: Russ Cox Date: Mon, 20 Oct 2014 16:16:46 +0000 (-0400) Subject: regexp: fix TestOnePassCutoff X-Git-Tag: go1.4beta1~76 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=22be4bfdbf8100cfff28c4053dcfd35370917993;p=gostls13.git 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://golang.org/cl/162860043 --- diff --git a/src/regexp/all_test.go b/src/regexp/all_test.go index 5fadb67c09..01ea3742a8 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) {