mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
358e52a7f5
A year ago I submitted a change to replace AnyError with tests for specific errors (see https://github.com/elves/elvish/commit/87656c99). This does something similar for DoesNotCompile. This ensures the test does what is implied and makes correlating specific unit tests with compilation errors easier. This includes a couple of changes to compilation error messages to improve readability (IMHO) but those are not the primary purpose of this change. Related #1560
31 lines
776 B
Go
31 lines
776 B
Go
package eval_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "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("var ns = (ns [&]); eq $ns $ns").Puts(true),
|
|
That("eq (ns [&]) (ns [&])").Puts(false),
|
|
That("eq (ns [&]) [&]").Puts(false),
|
|
|
|
That("var ns: = (ns [&a=b &x=y]); put $ns:a").Puts("b"),
|
|
That("var 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("set return~ = { }").DoesNotCompile("variable $return~ is read-only"),
|
|
)
|
|
}
|