elvish/pkg/eval/var_parse_test.go
Kurtis Rader 71cd3835bc Don't dot import pkg/tt
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00

56 lines
1.4 KiB
Go

package eval_test
import (
"testing"
. "src.elv.sh/pkg/eval"
"src.elv.sh/pkg/tt"
)
func TestSplitSigil(t *testing.T) {
tt.Test(t, tt.Fn("SplitSigil", SplitSigil), tt.Table{
Args("").Rets("", ""),
Args("x").Rets("", "x"),
Args("@x").Rets("@", "x"),
Args("a:b").Rets("", "a:b"),
Args("@a:b").Rets("@", "a:b"),
})
}
func TestSplitQName(t *testing.T) {
tt.Test(t, tt.Fn("SplitQName", SplitQName), tt.Table{
Args("").Rets("", ""),
Args("a").Rets("a", ""),
Args("a:").Rets("a:", ""),
Args("a:b").Rets("a:", "b"),
Args("a:b:").Rets("a:", "b:"),
Args("a:b:c").Rets("a:", "b:c"),
Args("a:b:c:").Rets("a:", "b:c:"),
})
}
func TestSplitQNameSegs(t *testing.T) {
tt.Test(t, tt.Fn("SplitQNameSegs", SplitQNameSegs), tt.Table{
Args("").Rets([]string{}),
Args("a").Rets([]string{"a"}),
Args("a:").Rets([]string{"a:"}),
Args("a:b").Rets([]string{"a:", "b"}),
Args("a:b:").Rets([]string{"a:", "b:"}),
Args("a:b:c").Rets([]string{"a:", "b:", "c"}),
Args("a:b:c:").Rets([]string{"a:", "b:", "c:"}),
})
}
func TestSplitIncompleteQNameNs(t *testing.T) {
tt.Test(t, tt.Fn("SplitIncompleteQNameNs", SplitIncompleteQNameNs), tt.Table{
Args("").Rets("", ""),
Args("a").Rets("", "a"),
Args("a:").Rets("a:", ""),
Args("a:b").Rets("a:", "b"),
Args("a:b:").Rets("a:b:", ""),
Args("a:b:c").Rets("a:b:", "c"),
Args("a:b:c:").Rets("a:b:c:", ""),
})
}