fix hanging on empty string

This commit is contained in:
gobwas 2016-05-14 22:26:18 +03:00
parent 1a9b5d0057
commit 49571a1557
3 changed files with 10 additions and 1 deletions

View File

@ -64,6 +64,9 @@ func TestGlob(t *testing.T) {
for _, test := range []test{
glob(true, "* ?at * eyes", "my cat has very bright eyes"),
glob(true, "", ""),
glob(false, "", "b"),
glob(true, "abc", "abc"),
glob(true, "a*c", "abc"),
glob(true, "a*c", "a12345c"),

View File

@ -152,7 +152,7 @@ func newLexer(source string) *lexer {
l := &lexer{
input: source,
state: lexRaw,
items: make(chan item, len(source)),
items: make(chan item, len(source)+1),
termPhrases: make(map[int]int),
}
return l

View File

@ -9,6 +9,12 @@ func TestLexGood(t *testing.T) {
pattern string
items []item
}{
{
pattern: "",
items: []item{
item{item_eof, ""},
},
},
{
pattern: "hello",
items: []item{