xgo/parser/ast_test.go

40 lines
728 B
Go
Raw Permalink Normal View History

package parser_test
import (
"testing"
2019-12-30 00:38:51 +03:00
"github.com/d5/tengo/v2/parser"
)
func TestIdentListString(t *testing.T) {
identListVar := &parser.IdentList{
List: []*parser.Ident{
{Name: "a"},
{Name: "b"},
{Name: "c"},
},
VarArgs: true,
}
expectedVar := "(a, b, ...c)"
if str := identListVar.String(); str != expectedVar {
2019-12-20 22:40:38 +03:00
t.Fatalf("expected string of %#v to be %s, got %s",
identListVar, expectedVar, str)
}
identList := &parser.IdentList{
List: []*parser.Ident{
{Name: "a"},
{Name: "b"},
{Name: "c"},
},
VarArgs: false,
}
expected := "(a, b, c)"
if str := identList.String(); str != expected {
2019-12-20 22:40:38 +03:00
t.Fatalf("expected string of %#v to be %s, got %s",
identList, expected, str)
}
}