1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
package parser_test
import (
"testing"
"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 {
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 {
t.Fatalf("expected string of %#v to be %s, got %s",
identList, expected, str)
}
}
|