aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/target/ruby.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/target/ruby.lux')
-rw-r--r--stdlib/source/test/lux/target/ruby.lux146
1 files changed, 101 insertions, 45 deletions
diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux
index 5a52dc1b8..281ffe594 100644
--- a/stdlib/source/test/lux/target/ruby.lux
+++ b/stdlib/source/test/lux/target/ruby.lux
@@ -234,6 +234,8 @@
items (random.list size random.safe_frac)
$class (# ! each (|>> %.nat (format "class_") /.local)
random.nat)
+ $sub_class (# ! each (|>> %.nat (format "sub_class_") /.local)
+ random.nat)
$method/0 (# ! each (|>> %.nat (format "method_") /.local)
random.nat)
$method/1 (|> random.nat
@@ -296,6 +298,32 @@
(/.do (/.code $method/1) (list (/.float single)) {.#None}))))
[(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
+ (_.for [/.module]
+ ($_ _.and
+ (_.cover [/.include/1]
+ (expression (|>> (:as Frac) (f.= (f.+ single single)))
+ (|> ($_ /.then
+ (/.set (list $class) (/.module [/.#parameters (list)
+ /.#body double]))
+ (/.set (list $sub_class) (/.class [/.#parameters (list)
+ /.#body (/.statement (/.include/1 $class))]))
+ (/.return (|> $sub_class
+ (/.new (list) {.#None})
+ (/.do (/.code $method/0) (list (/.float single)) {.#None}))))
+ [(list)] (/.lambda {.#None})
+ (/.apply_lambda/* (list)))))
+ (_.cover [/.extend/1]
+ (expression (|>> (:as Frac) (f.= (f.+ single single)))
+ (|> ($_ /.then
+ (/.set (list $class) (/.module [/.#parameters (list)
+ /.#body double]))
+ (/.set (list $sub_class) (/.class [/.#parameters (list)
+ /.#body (/.statement (/.extend/1 $class))]))
+ (/.return (|> $sub_class
+ (/.do (/.code $method/0) (list (/.float single)) {.#None}))))
+ [(list)] (/.lambda {.#None})
+ (/.apply_lambda/* (list)))))
+ ))
)))
(def: test|io
@@ -305,34 +333,67 @@
right (random.ascii/upper 5)
$old (# ! each /.local (random.ascii/upper 1))
$new (# ! each /.local (random.ascii/upper 2))
+ $it (# ! each /.local (random.ascii/upper 3))
.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)))))
+ (_.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)))))
+ ))
+ (_.for [/.stdin]
+ ($_ _.and
+ (_.cover [/.gets/0]
+ (expression (|>> (:as Text) (text#= (format left text.\n)))
+ (|> ($_ /.then
+ (/.statement (/.require/1 (/.string "stringio")))
+ (/.set (list $old) /.stdin)
+ (/.set (list /.stdin) (/.new (list (/.string (format left text.\n))) {.#None}
+ (/.manual "StringIO")))
+ (/.set (list $it) /.gets/0)
+ (/.set (list /.stdin) $old)
+ (/.return $it))
+ [(list)] (/.lambda {.#None})
+ (/.apply_lambda/* (list)))))
+ (_.cover [/.last_string_read]
+ (expression (|>> (:as Text) (text#= (format right text.\n)))
+ (|> ($_ /.then
+ (/.statement (/.require/1 (/.string "stringio")))
+ (/.set (list $old) /.stdin)
+ (/.set (list /.stdin) (/.new (list (/.string (format right text.\n))) {.#None}
+ (/.manual "StringIO")))
+ (/.set (list $it) /.gets/0)
+ (/.set (list /.stdin) $old)
+ (/.return /.last_string_read))
+ [(list)] (/.lambda {.#None})
+ (/.apply_lambda/* (list)))))
+ (_.cover [/.last_line_number_read]
+ (expression (|>> (:as Nat) (n.= 2))
+ /.last_line_number_read))
+ ))
)))
(def: test|computation
@@ -367,18 +428,6 @@
(/.float then))))
)))
-(def: test|expression
- Test
- (do [! random.monad]
- [dummy random.safe_frac
- expected random.safe_frac]
- (`` ($_ _.and
- (_.for [/.Literal]
- ..test|literal)
- (_.for [/.Computation]
- ..test|computation)
- ))))
-
(def: test|global
Test
(do [! random.monad]
@@ -397,11 +446,6 @@
(|>> (:as Text)
(text.ends_with? file)))
/.script_name))
- (_.cover [/.script_name]
- (expression (let [file (format (# file.default separator) packager.main_file)]
- (|>> (:as Text)
- (text.ends_with? file)))
- /.script_name))
(_.cover [/.input_record_separator]
(expression (|>> (:as Text)
(text#= text.\n))
@@ -635,6 +679,20 @@
))
)))
+(def: test|expression
+ Test
+ (do [! random.monad]
+ [dummy random.safe_frac
+ expected random.safe_frac]
+ (`` ($_ _.and
+ (_.for [/.Literal]
+ ..test|literal)
+ (_.for [/.Computation]
+ ..test|computation)
+ (_.for [/.Location]
+ ..test|location)
+ ))))
+
(def: test|label
Test
(do [! random.monad]
@@ -948,8 +1006,6 @@
..test|loop
(_.for [/.Block]
..test|function)
- (_.for [/.Location]
- ..test|location)
)))
(def: random_expression