|
|
|
@ -287,6 +287,11 @@ var reTests = []struct {
|
|
|
|
|
{`multiple words`, nil, `multiple words, yeah`, []Group{{0, 14}}},
|
|
|
|
|
{`[k]`, nil, `ab`, []Group{}},
|
|
|
|
|
{`a[-]?c`, nil, `ac`, []Group{{0, 2}}},
|
|
|
|
|
{`^(.+)?B`, nil, `AB`, []Group{{0, 2}}},
|
|
|
|
|
|
|
|
|
|
// At this point, the python test suite has a bunch
|
|
|
|
|
// of backreference tests. Since my engine doesn't
|
|
|
|
|
// implement backreferences, I've skipped those tests.
|
|
|
|
|
|
|
|
|
|
// Todo - add numeric range tests
|
|
|
|
|
}
|
|
|
|
@ -348,6 +353,22 @@ var groupTests = []struct {
|
|
|
|
|
{`(((((((((a)))))))))`, nil, `a`, []Match{[]Group{{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}}}},
|
|
|
|
|
{`(.*)c(.*)`, nil, `abcde`, []Match{[]Group{{0, 5}, {0, 2}, {3, 5}}}},
|
|
|
|
|
{`\((.*), (.*)\)`, nil, `(a, b)`, []Match{[]Group{{0, 6}, {1, 2}, {4, 5}}}},
|
|
|
|
|
|
|
|
|
|
// At this point, the python test suite has a bunch
|
|
|
|
|
// of backreference tests. Since my engine doesn't
|
|
|
|
|
// implement backreferences, I've skipped those tests.
|
|
|
|
|
|
|
|
|
|
{`(a)(b)c|ab`, nil, `ab`, []Match{[]Group{{0, 2}}}},
|
|
|
|
|
{`(a)+x`, nil, `aaax`, []Match{[]Group{{0, 4}, {2, 3}}}},
|
|
|
|
|
{`([ac])+x`, nil, `aacx`, []Match{[]Group{{0, 4}, {2, 3}}}},
|
|
|
|
|
{`([^/]*/)*sub1/`, nil, `d:msgs/tdir/sub1/trial/away.cpp`, []Match{[]Group{{0, 17}, {7, 12}}}},
|
|
|
|
|
{`([^.]*)\.([^:]*):[T ]+(.*)`, nil, `track1.title:TBlah blah blah`, []Match{[]Group{{0, 28}, {0, 6}, {7, 12}, {14, 28}}}},
|
|
|
|
|
{`([^N]*N)+`, nil, `abNNxyzN`, []Match{[]Group{{0, 8}, {4, 8}}}},
|
|
|
|
|
{`([^N]*N)+`, nil, `abNNxyz`, []Match{[]Group{{0, 4}, {3, 4}}}},
|
|
|
|
|
{`([abc]*)x`, nil, `abcx`, []Match{[]Group{{0, 4}, {0, 3}}}},
|
|
|
|
|
{`([abc]*)x`, nil, `abc`, []Match{}},
|
|
|
|
|
{`([xyz]*)x`, nil, `abcx`, []Match{[]Group{{3, 4}, {3, 3}}}},
|
|
|
|
|
{`(a)+b|aac`, nil, `aac`, []Match{[]Group{{0, 3}}}},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFindAllMatches(t *testing.T) {
|
|
|
|
|