aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/control/concurrency/frp.lux2
-rw-r--r--stdlib/source/test/lux/control/function/memo.lux2
-rw-r--r--stdlib/source/test/lux/macro.lux4
-rw-r--r--stdlib/source/test/lux/macro/code.lux2
-rw-r--r--stdlib/source/test/lux/macro/poly/json.lux47
-rw-r--r--stdlib/source/test/lux/macro/syntax/common.lux134
6 files changed, 164 insertions, 27 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux
index 4d9632b8c..6c52dc5ad 100644
--- a/stdlib/source/test/lux/control/concurrency/frp.lux
+++ b/stdlib/source/test/lux/control/concurrency/frp.lux
@@ -169,7 +169,7 @@
(list@= (list distint/0 distint/1 distint/2)
actual))))
(let [polling-delay 10
- wiggle-room (n.* 3 polling-delay)
+ wiggle-room (n.* 5 polling-delay)
amount-of-polls 5
total-delay (|> polling-delay
(n.* amount-of-polls)
diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux
index 564e37a87..a57adaa53 100644
--- a/stdlib/source/test/lux/control/function/memo.lux
+++ b/stdlib/source/test/lux/control/function/memo.lux
@@ -50,7 +50,7 @@
Test
(<| (_.covering /._)
(do {@ random.monad}
- [input (|> random.nat (:: @ map (|>> (n.% 5) (n.+ 22))))])
+ [input (|> random.nat (:: @ map (|>> (n.% 5) (n.+ 23))))])
(_.with-cover [/.Memo])
($_ _.and
(_.cover [/.closed /.none]
diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux
index 4875820b6..1851fb4a4 100644
--- a/stdlib/source/test/lux/macro.lux
+++ b/stdlib/source/test/lux/macro.lux
@@ -6,7 +6,8 @@
["." /]}
["." / #_
["#." code]
- ["#." syntax]
+ ["#." syntax
+ ["#/." common]]
["#." poly #_
["#/." equivalence]
["#/." functor]
@@ -18,6 +19,7 @@
($_ _.and
/code.test
/syntax.test
+ /syntax/common.test
/poly/equivalence.test
/poly/functor.test
/poly/json.test
diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux
index 0fc1c24be..00a805f26 100644
--- a/stdlib/source/test/lux/macro/code.lux
+++ b/stdlib/source/test/lux/macro/code.lux
@@ -45,7 +45,7 @@
[size (|> random.nat (:: @ map (n.% 3)))]
(random.list size (random.and random random))))
-(def: random
+(def: #export random
(Random Code)
(random.rec
(function (_ random)
diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux
index 5e0bcfbd4..55b2d2dd2 100644
--- a/stdlib/source/test/lux/macro/poly/json.lux
+++ b/stdlib/source/test/lux/macro/poly/json.lux
@@ -1,6 +1,5 @@
(.module:
[lux #*
- ["%" data/text/format (#+ format)]
["_" test (#+ Test)]
[abstract
codec
@@ -20,7 +19,8 @@
[data
["." bit]
["." maybe]
- ["." text]
+ ["." text
+ ["%" format (#+ format)]]
[number
["n" nat]
["." frac]]
@@ -37,7 +37,7 @@
[type
["." unit]]
[math
- ["r" random (#+ Random)]]
+ ["." random (#+ Random)]]
[time
["ti" instant]
["tda" date]
@@ -67,39 +67,39 @@
#list (List Frac)
#dictionary (d.Dictionary Text Frac)
#variant Variant
- #tuple [Bit Frac Text]
+ #tuple [Bit Text Frac]
#recursive Recursive
## #instant ti.Instant
## #duration tdu.Duration
#date tda.Date
- #grams (unit.Qty unit.Gram)
- })
+ #grams (unit.Qty unit.Gram)})
(def: gen-recursive
(Random Recursive)
- (r.rec (function (_ gen-recursive)
- (r.or r.frac
- (r.and r.frac gen-recursive)))))
+ (random.rec
+ (function (_ gen-recursive)
+ (random.or random.frac
+ (random.and random.frac gen-recursive)))))
(derived: recursive-equivalence (poly/equivalence.equivalence Recursive))
(def: qty
(All [unit] (Random (unit.Qty unit)))
- (|> r.int (:: r.monad map unit.in)))
+ (|> random.int (:: random.monad map unit.in)))
(def: gen-record
(Random Record)
- (do {@ r.monad}
- [size (:: @ map (n.% 2) r.nat)]
- ($_ r.and
- r.bit
- r.frac
- (r.unicode size)
- (r.maybe r.frac)
- (r.list size r.frac)
- (r.dictionary text.hash size (r.unicode size) r.frac)
- ($_ r.or r.bit (r.unicode size) r.frac)
- ($_ r.and r.bit r.frac (r.unicode size))
+ (do {@ random.monad}
+ [size (:: @ map (n.% 2) random.nat)]
+ ($_ random.and
+ random.bit
+ random.frac
+ (random.unicode size)
+ (random.maybe random.frac)
+ (random.list size random.frac)
+ (random.dictionary text.hash size (random.unicode size) random.frac)
+ ($_ random.or random.bit (random.unicode size) random.frac)
+ ($_ random.and random.bit (random.unicode size) random.frac)
..gen-recursive
## _instant.instant
## _duration.duration
@@ -112,5 +112,6 @@
(def: #export test
Test
- (<| (_.context (%.name (name-of /._)))
- ($codec.spec ..equivalence ..codec gen-record)))
+ (<| (_.covering /._)
+ (_.with-cover [/.codec]
+ ($codec.spec ..equivalence ..codec ..gen-record))))
diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux
new file mode 100644
index 000000000..1aaf851a9
--- /dev/null
+++ b/stdlib/source/test/lux/macro/syntax/common.lux
@@ -0,0 +1,134 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [math
+ ["." random (#+ Random)]]
+ [abstract
+ [monad (#+ do)]
+ ["." equivalence (#+ Equivalence)]]
+ [control
+ [pipe (#+ case>)]
+ ["." try]
+ ["<>" parser
+ ["<c>" code]]]
+ [data
+ ["." bit ("#@." equivalence)]
+ ["." name]
+ ["." text]
+ [number
+ ["n" nat]]
+ [collection
+ ["." list]]]
+ [macro
+ ["." code]]]
+ {1
+ ["." /
+ ["#." reader]
+ ["#." writer]]}
+ ["." /// #_
+ ["#." code]])
+
+(def: annotations-equivalence
+ (Equivalence /.Annotations)
+ (list.equivalence
+ (equivalence.product name.equivalence
+ code.equivalence)))
+
+(def: random-text
+ (Random Text)
+ (random.ascii/alpha 10))
+
+(def: random-name
+ (Random Name)
+ (random.and ..random-text ..random-text))
+
+(def: random-annotations
+ (Random /.Annotations)
+ (do {@ random.monad}
+ [size (:: @ map (|>> (n.% 3)) random.nat)]
+ (random.list size (random.and random-name
+ ///code.random))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.covering /reader._)
+ (_.covering /writer._)
+ ($_ _.and
+ (do random.monad
+ [expected random.bit]
+ (_.cover [/reader.export /writer.export]
+ (|> expected
+ /writer.export
+ (<c>.run /reader.export)
+ (case> (#try.Success actual)
+ (bit@= expected actual)
+
+ (#try.Failure error)
+ false))))
+ (_.with-cover [/.Annotations]
+ ($_ _.and
+ (do random.monad
+ [expected ..random-annotations]
+ (_.cover [/reader.annotations /writer.annotations]
+ (|> expected
+ /writer.annotations list
+ (<c>.run /reader.annotations)
+ (case> (#try.Success actual)
+ (:: ..annotations-equivalence = expected actual)
+
+ (#try.Failure error)
+ false))))
+ (_.cover [/.empty-annotations]
+ (|> /.empty-annotations
+ /writer.annotations list
+ (<c>.run /reader.annotations)
+ (case> (#try.Success actual)
+ (:: ..annotations-equivalence = /.empty-annotations actual)
+
+ (#try.Failure error)
+ false)))
+ ))
+ (do {@ random.monad}
+ [size (:: @ map (|>> (n.% 3)) random.nat)
+ expected (random.list size ..random-text)]
+ (_.cover [/.Type-Var /reader.type-variables /writer.type-variables]
+ (|> expected
+ /writer.type-variables
+ (<c>.run /reader.type-variables)
+ (case> (#try.Success actual)
+ (:: (list.equivalence text.equivalence) = expected actual)
+
+ (#try.Failure error)
+ false))))
+ (do {@ random.monad}
+ [size (:: @ map (|>> (n.% 3)) random.nat)
+ expected (: (Random /.Declaration)
+ (random.and ..random-text
+ (random.list size ..random-text)))]
+ (_.cover [/.Declaration /reader.declaration /writer.declaration]
+ (|> expected
+ /writer.declaration list
+ (<c>.run /reader.declaration)
+ (case> (#try.Success actual)
+ (let [equivalence (equivalence.product text.equivalence
+ (list.equivalence text.equivalence))]
+ (:: equivalence = expected actual))
+
+ (#try.Failure error)
+ false))))
+ (do {@ random.monad}
+ [expected (: (Random /.Typed-Input)
+ (random.and ///code.random
+ ///code.random))]
+ (_.cover [/.Typed-Input /reader.typed-input /writer.typed-input]
+ (|> expected
+ /writer.typed-input list
+ (<c>.run /reader.typed-input)
+ (case> (#try.Success actual)
+ (let [equivalence (equivalence.product code.equivalence code.equivalence)]
+ (:: equivalence = expected actual))
+
+ (#try.Failure error)
+ false))))
+ )))