aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/macro
diff options
context:
space:
mode:
authorEduardo Julian2020-12-29 23:29:54 -0400
committerEduardo Julian2020-12-29 23:29:54 -0400
commit02d27daeacac74785c2b0f4d1ce03d432377a36e (patch)
tree5129c496d136deb57880f202153e96f4f585e355 /stdlib/source/test/lux/macro
parent832a9361b632331e82a64c07baa560487ca8abde (diff)
Unified repository abstraction for Aedifex.
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/macro/syntax/common.lux48
-rw-r--r--stdlib/source/test/lux/macro/syntax/common/annotations.lux52
-rw-r--r--stdlib/source/test/lux/macro/syntax/common/definition.lux12
3 files changed, 60 insertions, 52 deletions
diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux
index 90a72ca26..429b7fc6e 100644
--- a/stdlib/source/test/lux/macro/syntax/common.lux
+++ b/stdlib/source/test/lux/macro/syntax/common.lux
@@ -29,61 +29,22 @@
["." /// #_
["#." code]]
["." / #_
+ ["#." annotations]
["#." check]
+ ["#." declaration]
["#." definition]
- ["#." export]
- ["#." declaration]])
-
-(def: annotations_equivalence
- (Equivalence /.Annotations)
- (list.equivalence
- (product.equivalence name.equivalence
- code.equivalence)))
+ ["#." export]])
(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
- (_.for [/.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)]
@@ -111,8 +72,9 @@
(#try.Failure error)
false))))
+ /annotations.test
/check.test
+ /declaration.test
/definition.test
/export.test
- /declaration.test
)))
diff --git a/stdlib/source/test/lux/macro/syntax/common/annotations.lux b/stdlib/source/test/lux/macro/syntax/common/annotations.lux
new file mode 100644
index 000000000..bc29a00f6
--- /dev/null
+++ b/stdlib/source/test/lux/macro/syntax/common/annotations.lux
@@ -0,0 +1,52 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]]}]
+ [control
+ ["." try]
+ [parser
+ ["<.>" code]]]
+ [data
+ [collection
+ ["." list]]]
+ [math
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
+ {1
+ ["." /]}
+ ["$." //// #_
+ ["#." code]])
+
+(def: #export random
+ (Random /.Annotations)
+ (let [word (random.ascii/alpha 10)
+ tag (random.and word word)]
+ (do {! random.monad}
+ [size (\ ! map (n.% 10) random.nat)]
+ (random.list size (random.and tag $////code.random)))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Annotations])
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+
+ (_.cover [/.empty]
+ (list.empty? /.empty))
+ (do random.monad
+ [expected ..random]
+ (_.cover [/.write /.parser]
+ (case (<code>.run /.parser
+ (list (/.write expected)))
+ (#try.Failure _)
+ false
+
+ (#try.Success actual)
+ (\ /.equivalence = expected actual)))))))
diff --git a/stdlib/source/test/lux/macro/syntax/common/definition.lux b/stdlib/source/test/lux/macro/syntax/common/definition.lux
index 937f5319a..a769df641 100644
--- a/stdlib/source/test/lux/macro/syntax/common/definition.lux
+++ b/stdlib/source/test/lux/macro/syntax/common/definition.lux
@@ -18,26 +18,20 @@
[meta
["." location]]]
{1
- ["." /
- [// (#+ Annotations)]]}
+ ["." /]}
["$."// #_
["#." check]
+ ["#." annotations]
["#//" /// #_
["#." code]]])
-(def: random_annotations
- (Random Annotations)
- (let [name (random.and (random.ascii/alpha 5)
- (random.ascii/alpha 5))]
- (random.list 5 (random.and name $////code.random))))
-
(def: #export random
(Random /.Definition)
($_ random.and
(random.ascii/alpha 5)
(random.or $//check.random
$////code.random)
- ..random_annotations
+ $//annotations.random
random.bit
))