diff options
Diffstat (limited to 'stdlib/source/test/lux/target/ruby.lux')
-rw-r--r-- | stdlib/source/test/lux/target/ruby.lux | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux index 7ec415b16..5a52dc1b8 100644 --- a/stdlib/source/test/lux/target/ruby.lux +++ b/stdlib/source/test/lux/target/ruby.lux @@ -298,6 +298,43 @@ (/.apply_lambda/* (list))))) ))) +(def: test|io + Test + (<| (do [! random.monad] + [left (random.ascii/upper 5) + right (random.ascii/upper 5) + $old (# ! each /.local (random.ascii/upper 1)) + $new (# ! each /.local (random.ascii/upper 2)) + .let [expected (format left right)]]) + (_.for [/.stdout]) + ($_ _.and + (_.cover [/.print/1] + (expression (|>> (:as Text) (text#= expected)) + (|> ($_ /.then + (/.statement (/.require/1 (/.string "stringio"))) + (/.set (list $old) /.stdout) + (/.set (list $new) (/.new (list) {.#None} (/.manual "StringIO"))) + (/.set (list /.stdout) $new) + (/.statement (/.print/1 (/.string left))) + (/.statement (/.print/1 (/.string right))) + (/.set (list /.stdout) $old) + (/.return (/.the "string" $new))) + [(list)] (/.lambda {.#None}) + (/.apply_lambda/* (list))))) + (_.cover [/.print/2] + (expression (|>> (:as Text) (text#= expected)) + (|> ($_ /.then + (/.statement (/.require/1 (/.string "stringio"))) + (/.set (list $old) /.stdout) + (/.set (list $new) (/.new (list) {.#None} (/.manual "StringIO"))) + (/.set (list /.stdout) $new) + (/.statement (/.print/2 (/.string left) (/.string right))) + (/.set (list /.stdout) $old) + (/.return (/.the "string" $new))) + [(list)] (/.lambda {.#None}) + (/.apply_lambda/* (list))))) + ))) + (def: test|computation Test (do [! random.monad] @@ -317,6 +354,7 @@ ..test|array ..test|hash ..test|object + ..test|io (_.cover [/.?] (let [expected (if test then else)] (expression (|>> (:as Frac) (f.= expected)) |