github.com/elves/elvish@v0.15.0/pkg/eval/vals/pipe_test.go (about) 1 package vals 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 8 "github.com/xiaq/persistent/hash" 9 ) 10 11 func TestPipe(t *testing.T) { 12 r, w, err := os.Pipe() 13 if err != nil { 14 panic(err) 15 } 16 defer r.Close() 17 defer w.Close() 18 19 TestValue(t, NewPipe(r, w)). 20 Kind("pipe"). 21 Bool(true). 22 Hash(hash.DJB(hash.UIntPtr(r.Fd()), hash.UIntPtr(w.Fd()))). 23 Repr(fmt.Sprintf("<pipe{%v %v}>", r.Fd(), w.Fd())). 24 Equal(NewPipe(r, w)). 25 NotEqual(123, "a string", NewPipe(w, r)) 26 }