diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/target/ruby.lux | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux index 5e2cecbde..2a2f9667d 100644 --- a/stdlib/source/test/lux/target/ruby.lux +++ b/stdlib/source/test/lux/target/ruby.lux @@ -230,7 +230,21 @@ (do [! random.monad] [size (# ! each (|>> (n.% 10) ++) random.nat) index (# ! each (n.% size) random.nat) - items (random.list size random.safe_frac)] + items (random.list size random.safe_frac) + $class (# ! each (|>> %.nat (format "class_") /.local) + random.nat) + $method/0 (# ! each (|>> %.nat (format "method_") /.local) + random.nat) + $method/1 (|> random.nat + (# ! each (|>> %.nat (format "method_") /.local)) + (random.only (|>> (# /.equivalence = $method/0) not))) + $arg/0 (# ! each (|>> %.nat (format "arg_") /.local) + random.nat) + $state (# ! each (|>> %.nat (format "instance_") /.instance) + random.nat) + single random.safe_frac + .let [double (/.function $method/0 (list $arg/0) + (/.return (/.+ $arg/0 $arg/0)))]] ($_ _.and (_.cover [/.the] (expression (|>> (:as Int) (i.= (.int size))) @@ -243,6 +257,44 @@ (|>> (:as Frac) (f.= expected))) (|> (/.array (list#each /.float items)) (/.do "at" (list (/.int (.int index))) {.#None})))) + (_.cover [/.class] + (expression (|>> (:as Frac) (f.= (f.+ single single))) + (|> ($_ /.then + (/.set (list $class) (/.class [/.#parameters (list) + /.#body double])) + (/.return (|> $class + (/.new (list) {.#None}) + (/.do (/.code $method/0) (list (/.float single)) {.#None})))) + [(list)] (/.lambda {.#None}) + (/.apply_lambda/* (list))))) + (_.cover [/.new /.initialize] + (expression (|>> (:as Frac) (f.= single)) + (|> ($_ /.then + (/.set (list $class) (/.class [/.#parameters (list) + /.#body ($_ /.then + (/.function /.initialize (list $arg/0) + (/.set (list $state) $arg/0)) + (/.function $method/0 (list) + (/.return $state)) + )])) + (/.return (|> $class + (/.new (list (/.float single)) {.#None}) + (/.do (/.code $method/0) (list) {.#None})))) + [(list)] (/.lambda {.#None}) + (/.apply_lambda/* (list))))) + (_.cover [/.alias_method/2] + (expression (|>> (:as Frac) (f.= (f.+ single single))) + (|> ($_ /.then + (/.set (list $class) (/.class [/.#parameters (list) + /.#body ($_ /.then + double + (/.statement (/.alias_method/2 (/.string (/.code $method/1)) + (/.string (/.code $method/0)))))])) + (/.return (|> $class + (/.new (list) {.#None}) + (/.do (/.code $method/1) (list (/.float single)) {.#None})))) + [(list)] (/.lambda {.#None}) + (/.apply_lambda/* (list))))) ))) (def: test|computation @@ -306,6 +358,16 @@ ($_ _.and (<| (_.for [/.Var]) ($_ _.and + (_.cover [/.defined?/1] + (and (expression (|>> (:as Bit)) + (|> (/.defined?/1 $foreign) + (/.= /.nil))) + (expression (|>> (:as Text) (text#= "local-variable")) + (|> ($_ /.then + (/.set (list $foreign) (/.float float/0)) + (/.return (/.defined?/1 $foreign))) + [(list)] (/.lambda {.#None}) + (/.apply_lambda/* (list)))))) (_.cover [/.LVar /.local /.set] (expression (|>> (:as Frac) (f.= (f.+ float/0 float/0))) (|> ($_ /.then @@ -534,7 +596,7 @@ (/.statement (/.raise (/.string error))) (/.return (/.float dummy))) (list [(list) $ex (/.return ($_ /.and - (/.do "kind_of?" (list (/.local "Array")) {.#None} /.latest_error_location) + (/.do "kind_of?" (list (: /.CVar (/.manual "Array"))) {.#None} /.latest_error_location) (/.> (/.int +0) (/.the "length" /.latest_error_location))))])) [(list)] (/.lambda {.#None}) (/.apply_lambda/* (list)))))) @@ -652,7 +714,7 @@ [(list $arg/0 $arg/1)] (/.lambda {.#None}) (/.apply_lambda/* (list (/.float float/0) (/.float float/1)))))) (_.cover [/.require/1] - (let [$JSON (/.local "JSON")] + (let [$JSON (: /.CVar (/.manual "JSON"))] (expression (|>> (:as Text) (text#= expected)) (|> ($_ /.then (/.statement (/.require/1 (/.string "json"))) |