diff options
author | Eduardo Julian | 2019-02-05 19:09:31 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-05 19:09:31 -0400 |
commit | 47b97c128bde837fa803a605f3e011a3e9ddd71c (patch) | |
tree | 5e8a84d1b1812ec4a157d4049c778ec2e4e434c4 /stdlib/source/test/lux/control/pipe.lux | |
parent | be5710d104e6ee085dcb9d871be0b80305e48f8b (diff) |
Integrated tests into normal source code.
Diffstat (limited to 'stdlib/source/test/lux/control/pipe.lux')
-rw-r--r-- | stdlib/source/test/lux/control/pipe.lux | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/control/pipe.lux b/stdlib/source/test/lux/control/pipe.lux new file mode 100644 index 000000000..aaaa18616 --- /dev/null +++ b/stdlib/source/test/lux/control/pipe.lux @@ -0,0 +1,72 @@ +(.module: + [lux #* + [control + [monad (#+ Monad do)] + pipe] + [data + ["." identity] + [text ("text/." equivalence) + format]] + [math + ["r" random]]] + lux/test) + +(context: "Pipes" + ($_ seq + (test "Can dismiss previous pipeline results and begin a new line." + (|> +20 + (i/* +3) + (i/+ +4) + (new> +0 inc) + (i/= +1))) + + (test "Can give names to piped values within a pipeline's scope." + (|> +5 + (let> X [(i/+ X X)]) + (i/= +10))) + + (test "Can do branching in pipelines." + (and (|> +5 + (cond> [i/even?] [(i/* +2)] + [i/odd?] [(i/* +3)] + [(new> -1)]) + (i/= +15)) + (|> +4 + (cond> [i/even?] [(i/* +2)] + [i/odd?] [(i/* +3)] + []) + (i/= +8)) + (|> +5 + (cond> [i/even?] [(i/* +2)] + [(new> -1)]) + (i/= -1)))) + + (test "Can loop within pipelines." + (|> +1 + (loop> [(i/< +10)] + [inc]) + (i/= +10))) + + (test "Can use monads within pipelines." + (|> +5 + (do> identity.monad + [(i/* +3)] + [(i/+ +4)] + [inc]) + (i/= +20))) + + (test "Can pattern-match against piped values." + (|> +5 + (case> +0 "zero" + +1 "one" + +2 "two" + +3 "three" + +4 "four" + +5 "five" + +6 "six" + +7 "seven" + +8 "eight" + +9 "nine" + _ "???") + (text/= "five"))) + )) |