fix tests

This commit is contained in:
gobwas 2019-03-12 22:15:41 +03:00
parent cd9e75ee86
commit bcbbef0a8d
3 changed files with 9 additions and 9 deletions

View File

@ -54,7 +54,7 @@ func main() {
for _, c := range strings.Split(*sep, ",") {
r, w := utf8.DecodeRuneInString(c)
if len(c) > w {
fmt.Println("only single charactered separators are allowed: %+q", c)
fmt.Printf("only single charactered separators are allowed: %+q\n", c)
os.Exit(1)
}
separators = append(separators, r)

View File

@ -113,7 +113,7 @@ func TestCompiler(t *testing.T) {
match.NewSingle(separators),
}),
match.NewAny(separators),
nil,
match.Nothing{},
),
},
{
@ -129,13 +129,13 @@ func TestCompiler(t *testing.T) {
sep: separators,
exp: match.NewTree(
match.NewText("/"),
nil,
match.Nothing{},
match.NewTree(
match.MustIndexedAnyOf(
match.NewText("z"),
match.NewText("ab"),
),
nil,
match.Nothing{},
match.NewSuper(),
),
),
@ -156,7 +156,7 @@ func TestCompiler(t *testing.T) {
match.NewSingle(separators),
}),
match.NewSuper(),
nil,
match.Nothing{},
),
},
{
@ -273,7 +273,7 @@ func TestCompiler(t *testing.T) {
),
exp: match.NewTree(
match.NewText("abc"),
nil,
match.Nothing{},
match.NewAnyOf(
match.NewSingle(nil),
match.NewList([]rune{'d', 'e', 'f'}, false),
@ -293,7 +293,7 @@ func TestCompiler(t *testing.T) {
match.NewRange('a', 'z', false),
match.NewRange('a', 'x', true),
}),
nil,
match.Nothing{},
match.NewSuper(),
),
},

View File

@ -40,8 +40,8 @@ func Optimize(m Matcher) (opt Matcher) {
}
var (
leftNil = v.left == nil
rightNil = v.right == nil
leftNil = v.left == nil || v.left == Nothing{}
rightNil = v.right == nil || v.right == Nothing{}
)
if leftNil && rightNil {
return NewText(txt.s)