mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-15 11:57:55 +08:00
32 lines
661 B
Go
32 lines
661 B
Go
package eval
|
|
|
|
import (
|
|
"strconv"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func strsEqual(s1 []string, s2 []string) bool {
|
|
if len(s1) == len(s2) {
|
|
for i := range s1 {
|
|
if s1[i] != s2[i] {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func TestNewEvaluator(t *testing.T) {
|
|
ev := NewEvaluator([]string{"foo=bar", "PATH=/usr/bin:/bin"})
|
|
pid := strconv.Itoa(syscall.Getpid())
|
|
if ev.globals["pid"].String(ev) != pid {
|
|
t.Errorf(`ev.globals["pid"] = %v, want %v`, ev.globals["pid"], pid)
|
|
}
|
|
searchPaths := []string{"/usr/bin", "/bin"}
|
|
if !strsEqual(ev.searchPaths, searchPaths) {
|
|
t.Errorf(`ev.searchPaths = %v, want %v`, ev.searchPaths, searchPaths)
|
|
}
|
|
}
|