From 4248cc22881a7eaa8f74bc426f2b0ba284b23153 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 23 Jul 2021 01:05:41 -0400 Subject: Automatically handling input/output conversions for methods in new JVM compiler. --- stdlib/source/test/lux.lux | 79 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 18 deletions(-) (limited to 'stdlib/source/test/lux.lux') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 20d21d74d..fcf33fa79 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -61,22 +61,6 @@ [_ (wrap [])] body))) -(def: identity - Test - (do {! random.monad} - [value random.nat - #let [object (: (Random (Atom Nat)) - (\ ! map atom.atom (wrap value)))] - self object] - ($_ _.and - (_.test "Every value is identical to itself." - (is? self self)) - (do ! - [other object] - (_.test "Values created separately can't be identical." - (not (is? self other)))) - ))) - (def: prelude_macros Test ($_ _.and @@ -739,12 +723,70 @@ dummy)))) ))) +(def: for_value + Test + (do random.monad + [left random.nat + right (random.ascii/lower 1)] + ($_ _.and + (_.cover [/.Either] + (and (exec + (: (/.Either Nat Text) + (#.Left left)) + true) + (exec + (: (/.Either Nat Text) + (#.Right right)) + true))) + (_.cover [/.Any] + (and (exec + (: /.Any + left) + true) + (exec + (: /.Any + right) + true))) + (_.cover [/.Nothing] + (and (exec + (: (-> /.Any /.Nothing) + (function (_ _) + (undefined))) + true) + (exec + (: (-> /.Any /.Int) + (function (_ _) + (: /.Int (undefined)))) + true))) + (_.cover [/.All] + (let [identity (: (/.All [a] (-> a a)) + (|>>))] + (and (exec + (: Nat + (identity left)) + true) + (exec + (: Text + (identity right)) + true)))) + (_.cover [/.Ex] + (let [hide (: (/.Ex [a] (-> Nat a)) + (|>>))] + (exec + (: /.Any + (hide left)) + true))) + (_.cover [/.is?] + (let [not_left (|> left inc dec)] + (and (/.is? left left) + (and (n.= not_left left) + (not (/.is? not_left left)))))) + ))) + (def: test Test (<| (_.covering /._) ($_ _.and - (<| (_.context "Identity.") - ..identity) (<| (_.context "Prelude macros.") ..prelude_macros) @@ -764,6 +806,7 @@ ..for_slot ..for_associative ..for_expansion + ..for_value ..sub_tests ))) -- cgit v1.2.3