summaryrefslogtreecommitdiff
path: root/libgo/go/regexp/exec_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/regexp/exec_test.go')
-rw-r--r--libgo/go/regexp/exec_test.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/libgo/go/regexp/exec_test.go b/libgo/go/regexp/exec_test.go
index 70d069c0611..4872cb3def4 100644
--- a/libgo/go/regexp/exec_test.go
+++ b/libgo/go/regexp/exec_test.go
@@ -24,8 +24,8 @@ import (
// complexity, over all possible strings over a given alphabet,
// up to a given size. Rather than try to link with RE2, we read a
// log file containing the test cases and the expected matches.
-// The log file, re2.txt, is generated by running 'make exhaustive-log'
-// in the open source RE2 distribution. http://code.google.com/p/re2/
+// The log file, re2-exhaustive.txt, is generated by running 'make log'
+// in the open source RE2 distribution https://github.com/google/re2/.
//
// The test file format is a sequence of stanzas like:
//
@@ -59,8 +59,8 @@ import (
// a capital letter are test names printed during RE2's test suite
// and are echoed into t but otherwise ignored.
//
-// At time of writing, re2.txt is 32 MB but compresses to 760 kB,
-// so we store re2.txt.gz in the repository and decompress it on the fly.
+// At time of writing, re2-exhaustive.txt is 59 MB but compresses to 385 kB,
+// so we store re2-exhaustive.txt.bz2 in the repository and decompress it on the fly.
//
func TestRE2Search(t *testing.T) {
testRE2(t, "testdata/re2-search.txt")
@@ -326,7 +326,7 @@ func same(x, y []int) bool {
// TestFowler runs this package's regexp API against the
// POSIX regular expression tests collected by Glenn Fowler
-// at http://www2.research.att.com/~gsf/testregex/.
+// at http://www2.research.att.com/~astopen/testregex/testregex.html.
func TestFowler(t *testing.T) {
files, err := filepath.Glob("testdata/*.dat")
if err != nil {
@@ -361,7 +361,7 @@ Reading:
break Reading
}
- // http://www2.research.att.com/~gsf/man/man1/testregex.html
+ // http://www2.research.att.com/~astopen/man/man1/testregex.html
//
// INPUT FORMAT
// Input lines may be blank, a comment beginning with #, or a test
@@ -713,3 +713,15 @@ func TestLongest(t *testing.T) {
t.Errorf("longest match was %q, want %q", g, w)
}
}
+
+// TestProgramTooLongForBacktrack tests that a regex which is too long
+// for the backtracker still executes properly.
+func TestProgramTooLongForBacktrack(t *testing.T) {
+ longRegex := MustCompile(`(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|twentyone|twentytwo|twentythree|twentyfour|twentyfive|twentysix|twentyseven|twentyeight|twentynine|thirty|thirtyone|thirtytwo|thirtythree|thirtyfour|thirtyfive|thirtysix|thirtyseven|thirtyeight|thirtynine|forty|fortyone|fortytwo|fortythree|fortyfour|fortyfive|fortysix|fortyseven|fortyeight|fortynine|fifty|fiftyone|fiftytwo|fiftythree|fiftyfour|fiftyfive|fiftysix|fiftyseven|fiftyeight|fiftynine|sixty|sixtyone|sixtytwo|sixtythree|sixtyfour|sixtyfive|sixtysix|sixtyseven|sixtyeight|sixtynine|seventy|seventyone|seventytwo|seventythree|seventyfour|seventyfive|seventysix|seventyseven|seventyeight|seventynine|eighty|eightyone|eightytwo|eightythree|eightyfour|eightyfive|eightysix|eightyseven|eightyeight|eightynine|ninety|ninetyone|ninetytwo|ninetythree|ninetyfour|ninetyfive|ninetysix|ninetyseven|ninetyeight|ninetynine|onehundred)`)
+ if !longRegex.MatchString("two") {
+ t.Errorf("longRegex.MatchString(\"two\") was false, want true")
+ }
+ if longRegex.MatchString("xxx") {
+ t.Errorf("longRegex.MatchString(\"xxx\") was true, want false")
+ }
+}