aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux.lux')
-rw-r--r--stdlib/source/test/lux.lux66
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.")