aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-12-29 00:38:21 -0400
committerEduardo Julian2020-12-29 00:38:21 -0400
commit832a9361b632331e82a64c07baa560487ca8abde (patch)
tree5fec882399315def4d789ecef1746d90e761df93 /stdlib/source/test/lux/type.lux
parent92dca9f487c625d27f6c291784ef709b0cc13a72 (diff)
Moved "lux/data/number" to "lux/math/number".
Diffstat (limited to 'stdlib/source/test/lux/type.lux')
-rw-r--r--stdlib/source/test/lux/type.lux116
1 files changed, 59 insertions, 57 deletions
diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux
index c06b89478..168ed29d1 100644
--- a/stdlib/source/test/lux/type.lux
+++ b/stdlib/source/test/lux/type.lux
@@ -1,17 +1,19 @@
(.module:
[lux (#- type)
["%" data/text/format (#+ format)]
- ["M" abstract/monad (#+ do)]
- ["r" math/random (#+ Random)]
["_" test (#+ Test)]
+ [abstract
+ ["." monad (#+ do)]]
[control
pipe]
[data
["." maybe]
- [number
- ["n" nat]]
[collection
- ["." list]]]]
+ ["." list]]]
+ [math
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / ("#\." equivalence)]}
["." / #_
@@ -21,41 +23,41 @@
["#." resource]])
(def: short
- (r.Random Text)
- (do {! r.monad}
- [size (|> r.nat (\ ! map (n.% 10)))]
- (r.unicode size)))
+ (Random Text)
+ (do {! random.monad}
+ [size (|> random.nat (\ ! map (n.% 10)))]
+ (random.unicode size)))
(def: name
- (r.Random Name)
- (r.and ..short ..short))
+ (Random Name)
+ (random.and ..short ..short))
(def: #export random
- (r.Random Type)
- (let [(^open "R\.") r.monad]
- (r.rec (function (_ recur)
- (let [pairG (r.and recur recur)
- idG r.nat
- quantifiedG (r.and (R\wrap (list)) recur)]
- ($_ r.or
- (r.and ..short (R\wrap (list)))
- pairG
- pairG
- pairG
- idG
- idG
- idG
- quantifiedG
- quantifiedG
- pairG
- (r.and ..name recur)
- ))))))
+ (Random Type)
+ (let [(^open "R\.") random.monad]
+ (random.rec (function (_ recur)
+ (let [pairG (random.and recur recur)
+ idG random.nat
+ quantifiedG (random.and (R\wrap (list)) recur)]
+ ($_ random.or
+ (random.and ..short (R\wrap (list)))
+ pairG
+ pairG
+ pairG
+ idG
+ idG
+ idG
+ quantifiedG
+ quantifiedG
+ pairG
+ (random.and ..name recur)
+ ))))))
(def: #export test
Test
(<| (_.context (%.name (name_of /._)))
($_ _.and
- (do r.monad
+ (do random.monad
[sample ..random]
(_.test "Every type is equal to itself."
(\ /.equivalence = sample sample)))
@@ -83,18 +85,18 @@
(\ /.equivalence =
(/.un_name base)
(/.un_name aliased))))))
- (do {! r.monad}
- [size (|> r.nat (\ ! map (n.% 3)))
+ (do {! random.monad}
+ [size (|> random.nat (\ ! map (n.% 3)))
members (|> ..random
- (r.filter (function (_ type)
- (case type
- (^or (#.Sum _) (#.Product _))
- #0
+ (random.filter (function (_ type)
+ (case type
+ (^or (#.Sum _) (#.Product _))
+ #0
- _
- #1)))
+ _
+ #1)))
(list.repeat size)
- (M.seq !))
+ (monad.seq !))
#let [(^open "/\.") /.equivalence
(^open "list\.") (list.equivalence /.equivalence)]]
(`` ($_ _.and
@@ -109,17 +111,17 @@
["tuple" /.tuple /.flatten_tuple Any]
))
)))
- (do {! r.monad}
- [size (|> r.nat (\ ! map (n.% 3)))
- members (M.seq ! (list.repeat size ..random))
+ (do {! random.monad}
+ [size (|> random.nat (\ ! map (n.% 3)))
+ members (monad.seq ! (list.repeat size ..random))
extra (|> ..random
- (r.filter (function (_ type)
- (case type
- (^or (#.Function _) (#.Apply _))
- #0
+ (random.filter (function (_ type)
+ (case type
+ (^or (#.Function _) (#.Apply _))
+ #0
- _
- #1))))
+ _
+ #1))))
#let [(^open "/\.") /.equivalence
(^open "list\.") (list.equivalence /.equivalence)]]
($_ _.and
@@ -132,16 +134,16 @@
(let [[tfunc tparams] (|> extra (/.application members) /.flatten_application)]
(n.= (list.size members) (list.size tparams))))
))
- (do {! r.monad}
- [size (|> r.nat (\ ! map (n.% 3)))
+ (do {! random.monad}
+ [size (|> random.nat (\ ! map (n.% 3)))
extra (|> ..random
- (r.filter (function (_ type)
- (case type
- (^or (#.UnivQ _) (#.ExQ _))
- #0
+ (random.filter (function (_ type)
+ (case type
+ (^or (#.UnivQ _) (#.ExQ _))
+ #0
- _
- #1))))
+ _
+ #1))))
#let [(^open "/\.") /.equivalence]]
(`` ($_ _.and
(~~ (template [<desc> <ctor> <dtor>]