github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/pkg/eval/ns_test.go (about) 1 package eval_test 2 3 import ( 4 "testing" 5 6 "src.elv.sh/pkg/eval/errs" 7 . "src.elv.sh/pkg/eval/evaltest" 8 ) 9 10 func TestNs(t *testing.T) { 11 Test(t, 12 That("kind-of (ns [&])").Puts("ns"), 13 // A Ns is only equal to itself 14 That("ns = (ns [&]); eq $ns $ns").Puts(true), 15 That("eq (ns [&]) (ns [&])").Puts(false), 16 That("eq (ns [&]) [&]").Puts(false), 17 18 That(`ns: = (ns [&a=b &x=y]); put $ns:a`).Puts("b"), 19 That(`ns: = (ns [&a=b &x=y]); put $ns:[a]`).Puts("b"), 20 // Test multi-key ns when sorting is possible 21 That(`keys (ns [&a=b])`).Puts("a"), 22 That(`has-key (ns [&a=b &x=y]) a`).Puts(true), 23 That(`has-key (ns [&a=b &x=y]) b`).Puts(false), 24 ) 25 } 26 27 func TestBuiltinFunctionsReadOnly(t *testing.T) { 28 Test(t, 29 That("return~ = { }").Throws(errs.SetReadOnlyVar{VarName: "return~"}, "return~"), 30 ) 31 }