github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/eval/ns_test.go (about)

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