forked from mirror/glob
fix hanging on empty string
This commit is contained in:
parent
1a9b5d0057
commit
49571a1557
|
@ -64,6 +64,9 @@ func TestGlob(t *testing.T) {
|
||||||
for _, test := range []test{
|
for _, test := range []test{
|
||||||
glob(true, "* ?at * eyes", "my cat has very bright eyes"),
|
glob(true, "* ?at * eyes", "my cat has very bright eyes"),
|
||||||
|
|
||||||
|
glob(true, "", ""),
|
||||||
|
glob(false, "", "b"),
|
||||||
|
|
||||||
glob(true, "abc", "abc"),
|
glob(true, "abc", "abc"),
|
||||||
glob(true, "a*c", "abc"),
|
glob(true, "a*c", "abc"),
|
||||||
glob(true, "a*c", "a12345c"),
|
glob(true, "a*c", "a12345c"),
|
||||||
|
|
2
lexer.go
2
lexer.go
|
@ -152,7 +152,7 @@ func newLexer(source string) *lexer {
|
||||||
l := &lexer{
|
l := &lexer{
|
||||||
input: source,
|
input: source,
|
||||||
state: lexRaw,
|
state: lexRaw,
|
||||||
items: make(chan item, len(source)),
|
items: make(chan item, len(source)+1),
|
||||||
termPhrases: make(map[int]int),
|
termPhrases: make(map[int]int),
|
||||||
}
|
}
|
||||||
return l
|
return l
|
||||||
|
|
|
@ -9,6 +9,12 @@ func TestLexGood(t *testing.T) {
|
||||||
pattern string
|
pattern string
|
||||||
items []item
|
items []item
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
pattern: "",
|
||||||
|
items: []item{
|
||||||
|
item{item_eof, ""},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pattern: "hello",
|
pattern: "hello",
|
||||||
items: []item{
|
items: []item{
|
||||||
|
|
Loading…
Reference in New Issue