Regexp: succeed on empty match at end of input

This commit is contained in:
2025-04-02 14:06:12 -06:00
parent 1892a97070
commit 4e157f7a0e
2 changed files with 9 additions and 1 deletions

View File

@ -61,6 +61,14 @@ func TestRegexp(t *testing.T) {
must.NoError(t, err)
test.StrContains(t, result.Message().Got(), "hella")
})
t.Run("succeeds on empty matches", func(t *testing.T) {
p := pbytes.Regexp(".*")
result, err := p(gigaparsec.MakeState(strings.NewReader("")))
succeeded, value, _ := result.Status()
must.NoError(t, err)
must.True(t, succeeded)
must.EqOp(t, "", value)
})
}
func TestRuneReader(t *testing.T) {