diff options
author | Eduardo Julian | 2021-02-07 04:56:58 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-02-07 04:56:58 -0400 |
commit | d99c47989a1047cd24019fd5ce434e701b5d3519 (patch) | |
tree | 19bfb0f5e4713e5dcd0c71bbd7b88d09d75dfe5d /stdlib/source/test/lux.lux | |
parent | 571d816dfd0b056a1649f5057867abbfa4421f5d (diff) |
Mo' updates, less problems.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux.lux | 66 |
1 files changed, 14 insertions, 52 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index f1200381a..a39671ea4 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -93,38 +93,9 @@ (check_neighbors odd? value) (check_neighbors even? value)))))) -(type: (Choice a) - (-> a a a)) - -(type: (Order a) - (-> a a Bit)) - (type: (Equivalence a) (-> a a Bit)) -(def: (choice rand_gen = [< choose]) - (All [a] (-> (Random a) (Equivalence a) [(Order a) (Choice a)] Test)) - (do random.monad - [left rand_gen - right rand_gen - #let [choice (choose left right)]] - ($_ _.and - (_.test "The choice between 2 values is one of them." - (or (= left choice) - (= right choice))) - (_.test "The choice between 2 values implies an order relationship between them." - (if (= left choice) - (< right choice) - (< left choice)))))) - -(def: (minimum_and_maximum rand_gen = min' max') - (All [a] (-> (Random a) (Equivalence a) [(Order a) (Choice a)] [(Order a) (Choice a)] Test)) - ($_ _.and - (<| (_.context "Minimum.") - (choice rand_gen = min')) - (<| (_.context "Maximum.") - (choice rand_gen = max')))) - (def: (conversion rand_gen forward backward =) (All [a b] (-> (Random a) (-> a b) (-> b a) (Equivalence a) Test)) (do random.monad @@ -213,6 +184,18 @@ @.js on_valid_host} on_default)))))) +(def: conversion_tests + Test + (`` ($_ _.and + (~~ (template [<=> <forward> <backward> <gen>] + [(<| (_.context (format (%.name (name_of <forward>)) + " " (%.name (name_of <backward>)))) + (..conversion <gen> <forward> <backward> <=>))] + + [i.= .nat .int (random\map (i.% +1,000,000) random.int)] + [n.= .int .nat (random\map (n.% 1,000,000) random.nat)] + ))))) + (def: sub_tests Test (let [tail (: (List Test) @@ -236,6 +219,7 @@ )))) (def: test + Test (<| (_.context (name.module (name_of /._))) ($_ _.and (<| (_.context "Identity.") @@ -248,30 +232,8 @@ (..even_or_odd random.nat n.even? n.odd?)) (<| (_.context "Integers.") (..even_or_odd random.int i.even? i.odd?)))) - (<| (_.context "Minimum and maximum.") - (`` ($_ _.and - (~~ (template [<=> <lt> <min> <gt> <max> <gen> <context>] - [(<| (_.context <context>) - (..minimum_and_maximum <gen> <=> [<lt> <min>] [<gt> <max>]))] - - [i.= i.< i.min i.> i.max random.int "Integers."] - [n.= n.< n.min n.> n.max random.nat "Natural numbers."] - [r.= r.< r.min r.> r.max random.rev "Revolutions."] - [f.= f.< f.min f.> f.max random.safe_frac "Fractions."] - ))))) (<| (_.context "Conversion.") - (`` ($_ _.and - (~~ (template [<=> <forward> <backward> <gen>] - [(<| (_.context (format (%.name (name_of <forward>)) - " " (%.name (name_of <backward>)))) - (..conversion <gen> <forward> <backward> <=>))] - - [i.= .nat .int (random\map (i.% +1,000,000) random.int)] - [n.= .int .nat (random\map (n.% 1,000,000) random.nat)] - [i.= i.frac f.int (random\map (i.% +1,000,000) random.int)] - [f.= f.int i.frac (random\map (|>> (i.% +1,000,000) i.frac) random.int)] - [r.= r.frac f.rev frac_rev] - ))))) + ..conversion_tests) (<| (_.context "Prelude macros.") ..prelude_macros) (<| (_.context "Templates.") |