elvish/pkg/eval/builtin_fn_flow_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

24 lines
681 B
Go

package eval
import "testing"
func TestBuiltinFnFlow(t *testing.T) {
Test(t,
That(`run-parallel { put lorem } { echo ipsum }`).
Puts("lorem").Prints("ipsum\n"),
That(`put 1 233 | each $put~`).Puts("1", "233"),
That(`echo "1\n233" | each $put~`).Puts("1", "233"),
That(`each $put~ [1 233]`).Puts("1", "233"),
That(`range 10 | each [x]{ if (== $x 4) { break }; put $x }`).
Puts(0.0, 1.0, 2.0, 3.0),
That(`range 10 | each [x]{ if (== $x 4) { fail haha }; put $x }`).
Puts(0.0, 1.0, 2.0, 3.0).ThrowsAny(),
// TODO(xiaq): Test that "each" does not close the stdin.
// TODO: test peach
That(`fail haha`).ThrowsAny(),
That(`return`).Throws(Return),
)
}