elvish/pkg/eval/builtin_fn_env_test.go
Qi Xiao ca945dcb7f pkg/eval: TestCase.Errors{With,} -> Throws{,Any}.
This is in preparation for supporting compilation errors. Also did some
cleanups.
2020-01-08 23:09:19 +00:00

34 lines
786 B
Go

package eval
import (
"os"
"testing"
"github.com/elves/elvish/pkg/eval/vals"
)
func TestBuiltinFnEnv(t *testing.T) {
oldpath := os.Getenv("PATH")
listSep := string(os.PathListSeparator)
Test(t,
That(`get-env var`).Throws(errNonExistentEnvVar),
That(`set-env var test1`),
That(`get-env var`).Puts("test1"),
That(`put $E:var`).Puts("test1"),
That(`set-env var test2`),
That(`get-env var`).Puts("test2"),
That(`put $E:var`).Puts("test2"),
That(`has-env var`).Puts(true),
That(`unset-env var`),
That(`has-env var`).Puts(false),
That(`set-env PATH /test-path`),
That(`put $paths`).Puts(vals.MakeList("/test-path")),
That(`paths = [/test-path2 $@paths]`),
That(`get-env PATH`).Puts("/test-path2"+listSep+"/test-path"),
)
os.Setenv("PATH", oldpath)
}