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.lux103
1 files changed, 68 insertions, 35 deletions
diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux
index 86a817703..7723cd776 100644
--- a/stdlib/source/test/lux/target/ruby.lux
+++ b/stdlib/source/test/lux/target/ruby.lux
@@ -5,7 +5,9 @@
["[0]" ffi]
[abstract
[monad {"+" do}]
- ["[0]" predicate]]
+ ["[0]" predicate]
+ [\\specification
+ ["$[0]" equivalence]]]
[control
["[0]" maybe ("[1]#[0]" functor)]
["[0]" try {"+" Try} ("[1]#[0]" functor)]]
@@ -306,7 +308,7 @@
(|> ($_ /.then
(/.set (list $foreign) (/.+ $foreign $foreign))
(/.return $foreign))
- (/.lambda {.#None} (list $foreign))
+ [(list $foreign)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.float float/0))))))
))
(_.cover [/.Access]
@@ -316,7 +318,7 @@
(/.set (list $foreign) (/.array (list $foreign)))
(/.set (list @) (/.+ @ @))
(/.return @))
- (/.lambda {.#None} (list $foreign))
+ [(list $foreign)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.float float/0))))))
(expression (|>> (:as Frac) (f.= (f.+ float/0 float/0)))
(let [@ (/.item field $foreign)]
@@ -324,7 +326,7 @@
(/.set (list $foreign) (/.hash (list [field $foreign])))
(/.set (list @) (/.+ @ @))
(/.return @))
- (/.lambda {.#None} (list $foreign))
+ [(list $foreign)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.float float/0))))))
))
)))
@@ -359,7 +361,7 @@
(/.set (list $inner_index) (/.+ (/.int +1) $inner_index))
))
(/.return $output))
- (/.lambda {.#None} (list $input))
+ [(list $input)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.int input)))))))
(_.cover [/.next]
(let [expected (i.* (.int (n.- expected_inner_iterations full_inner_iterations)) input)]
@@ -375,7 +377,7 @@
(/.set (list $output) (/.+ $input $output))
))
(/.return $output))
- (/.lambda {.#None} (list $input))
+ [(list $input)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.int input)))))))
)))
@@ -400,7 +402,7 @@
(/.set (list $index) (/.+ (/.int +1) $index))
))
(/.return $output))
- (/.lambda {.#None} (list $input))
+ [(list $input)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.int input))))))
(_.cover [/.for_in]
(expression (|>> (:as Int) (i.= expected))
@@ -409,7 +411,7 @@
(/.for_in $index (/.array (list.repeated iterations (/.int input)))
(/.set (list $output) (/.+ $index $output)))
(/.return $output))
- (/.lambda {.#None} (list $input))
+ [(list $input)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.int input))))))
..test|label
)))
@@ -420,13 +422,19 @@
[expected random.safe_frac
dummy (random.only (|>> (f.= expected) not)
random.safe_frac)
- $ex (# ! each /.local (random.ascii/lower 10))]
+ $ex (# ! each /.local (random.ascii/lower 10))
+
+ expected_tag random.int
+ dummy_tag (random.only (|>> (i.= expected_tag) not)
+ random.int)
+ .let [expected_tag (/.int expected_tag)
+ dummy_tag (/.int dummy_tag)]]
($_ _.and
(_.cover [/.begin]
(expression (|>> (:as Frac) (f.= expected))
(|> (/.begin (/.return (/.float expected))
(list [(list) $ex (/.return (/.float dummy))]))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
(_.cover [/.Rescue /.throw/1]
(expression (|>> (:as Frac) (f.= expected))
@@ -434,8 +442,37 @@
(/.throw/1 (/.string ""))
(/.return (/.float dummy)))
(list [(list) $ex (/.return (/.float expected))]))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
+ (/.apply_lambda/* (list)))))
+ (_.cover [/.raise]
+ (expression (|>> (:as Frac) (f.= expected))
+ (|> (/.begin ($_ /.then
+ (/.statement (/.raise (/.string "")))
+ (/.return (/.float dummy)))
+ (list [(list) $ex (/.return (/.float expected))]))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
+ (_.cover [/.catch /.throw/2]
+ (and (expression (|>> (:as Frac) (f.= expected))
+ (<| (/.apply_lambda/* (list))
+ (/.lambda {.#None}) [(list)]
+ /.return
+ (/.catch expected_tag) [(list)]
+ (/.throw/2 expected_tag (/.float expected))))
+ (expression (|>> (:as Frac) (f.= expected))
+ (<| (/.apply_lambda/* (list))
+ (/.lambda {.#None}) [(list)]
+ /.return
+ (/.catch expected_tag) [(list)]
+ /.statement (/.catch dummy_tag) [(list)]
+ (/.throw/2 expected_tag (/.float expected))))
+ (expression (|>> (:as Frac) (f.= expected))
+ (<| (/.apply_lambda/* (list))
+ (/.lambda {.#None}) [(list)]
+ /.return
+ (/.catch dummy_tag) [(list)]
+ /.statement (/.catch expected_tag) [(list)]
+ (/.throw/2 expected_tag (/.float expected))))))
)))
(def: test|function
@@ -456,18 +493,18 @@
(_.cover [/.lambda /.return]
(and (expression (|>> (:as Frac) (f.= float/0))
(|> (/.return (/.float float/0))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list))))
(expression (|>> (:as Frac) f.nat (n.= iterations))
- (|> (/.lambda {.#Some $self} (list $arg/0)
- (/.return (/.? (/.< (/.int (.int iterations)) $arg/0)
- (/.apply_lambda/* (list (/.+ (/.int +1) $arg/0)) $self)
- $arg/0)))
+ (|> (/.return (/.? (/.< (/.int (.int iterations)) $arg/0)
+ (/.apply_lambda/* (list (/.+ (/.int +1) $arg/0)) $self)
+ $arg/0))
+ [(list $arg/0)] (/.lambda {.#Some $self})
(/.apply_lambda/* (list (/.int +0)))))))
(_.cover [/.apply_lambda/*]
(expression (|>> (:as Frac) (f.= ($_ f.+ float/0 float/1 float/2)))
(|> (/.return ($_ /.+ $arg/0 $arg/1 $arg/2))
- (/.lambda {.#None} (list $arg/0 $arg/1 $arg/2))
+ [(list $arg/0 $arg/1 $arg/2)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.float float/0) (/.float float/1) (/.float float/2))))))
(_.cover [/.function]
(expression (|>> (:as Frac) f.nat (n.= iterations))
@@ -477,7 +514,7 @@
(/.apply/1 $self (/.+ (/.int +1) $arg/0))
$arg/0)))
(/.return (/.apply/1 $self (/.int +0))))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
(_.cover [/.apply/1]
(expression (|>> (:as Frac) (f.= float/0))
@@ -485,7 +522,7 @@
(/.function $self (list $arg/0)
(/.return $arg/0))
(/.return (/.apply/1 $self (/.float float/0))))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
(_.cover [/.apply/2]
(expression (|>> (:as Frac) (f.= ($_ f.+ float/0 float/1)))
@@ -493,15 +530,7 @@
(/.function $self (list $arg/0 $arg/1)
(/.return ($_ /.+ $arg/0 $arg/1)))
(/.return (/.apply/2 $self (/.float float/0) (/.float float/1))))
- (/.lambda {.#None} (list))
- (/.apply_lambda/* (list)))))
- (_.cover [/.apply/3]
- (expression (|>> (:as Frac) (f.= ($_ f.+ float/0 float/1 float/2)))
- (|> ($_ /.then
- (/.function $self (list $arg/0 $arg/1 $arg/2)
- (/.return ($_ /.+ $arg/0 $arg/1 $arg/2)))
- (/.return (/.apply/3 $self (/.float float/0) (/.float float/1) (/.float float/2))))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
(_.cover [/.apply/*]
(expression (|>> (:as Frac) (f.= ($_ f.+ float/0 float/1 float/2)))
@@ -509,7 +538,7 @@
(/.function $self (list $arg/0 $arg/1 $arg/2)
(/.return ($_ /.+ $arg/0 $arg/1 $arg/2)))
(/.return (/.apply/* (list (/.float float/0) (/.float float/1) (/.float float/2)) {.#None} $self)))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
... (_.cover [/.new]
... (let [$this (/.local "this")]
@@ -544,7 +573,7 @@
(|> (/.if (/.bool ???)
(/.return (/.float float/0))
(/.return (/.float float/1)))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
(_.cover [/.when]
(expression (|>> (:as Frac) (f.= (if ??? float/0 float/1)))
@@ -552,7 +581,7 @@
(/.when (/.bool ???)
(/.return (/.float float/0)))
(/.return (/.float float/1)))
- (/.lambda {.#None} (list))
+ [(list)] (/.lambda {.#None})
(/.apply_lambda/* (list)))))
)))
@@ -571,19 +600,20 @@
(|> ($_ /.then
(/.statement (/.+ $arg/0 $arg/0))
(/.return $arg/0))
- (/.lambda {.#None} (list $arg/0))
+ [(list $arg/0)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.float float/0))))))
(_.cover [/.then]
(expression (|>> (:as Frac) (f.= float/0))
(|> ($_ /.then
(/.return $arg/0)
(/.return $arg/1))
- (/.lambda {.#None} (list $arg/0 $arg/1))
+ [(list $arg/0 $arg/1)] (/.lambda {.#None})
(/.apply_lambda/* (list (/.float float/0) (/.float float/1))))))
..test|exception
- ..test|function
..test|branching
..test|loop
+ (_.for [/.Block]
+ ..test|function)
(_.for [/.Location]
..test/location)
)))
@@ -632,10 +662,13 @@
(<| (_.covering /._)
(_.for [/.Code])
($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random_expression))
+
(_.cover [/.code /.manual]
(|> (/.manual (/.code expected))
(: /.Expression)
- (# /.code_equivalence = expected)))
+ (# /.equivalence = expected)))
(_.for [/.Expression]
..test|expression)
(_.for [/.Statement]