elvish/pkg/eval/ns_test.go
Qi Xiao 7b66e9f104 Minor fixups for #1273.
Also fix a test broken by bad merge.
2021-05-02 00:13:22 +01:00

32 lines
798 B
Go

package eval_test
import (
"testing"
"src.elv.sh/pkg/eval/errs"
. "src.elv.sh/pkg/eval/evaltest"
)
func TestNs(t *testing.T) {
Test(t,
That("kind-of (ns [&])").Puts("ns"),
// A Ns is only equal to itself
That("ns = (ns [&]); eq $ns $ns").Puts(true),
That("eq (ns [&]) (ns [&])").Puts(false),
That("eq (ns [&]) [&]").Puts(false),
That(`ns: = (ns [&a=b &x=y]); put $ns:a`).Puts("b"),
That(`ns: = (ns [&a=b &x=y]); put $ns:[a]`).Puts("b"),
// Test multi-key ns when sorting is possible
That(`keys (ns [&a=b])`).Puts("a"),
That(`has-key (ns [&a=b &x=y]) a`).Puts(true),
That(`has-key (ns [&a=b &x=y]) b`).Puts(false),
)
}
func TestBuiltinFunctionsReadOnly(t *testing.T) {
Test(t,
That("return~ = { }").Throws(errs.SetReadOnlyVar{VarName: "return~"}, "return~"),
)
}