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.lux79
1 files changed, 61 insertions, 18 deletions
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
)))