mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
066b48cfd2
This fixes #1211.
32 lines
813 B
Go
32 lines
813 B
Go
package eval_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/elves/elvish/pkg/eval/evaltest"
|
|
"github.com/elves/elvish/pkg/eval/vars"
|
|
)
|
|
|
|
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(vars.ErrSetReadOnlyVar, "return~ = { }"),
|
|
)
|
|
}
|