aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2021-09-08 00:22:45 -0400
committerEduardo Julian2021-09-08 00:22:45 -0400
commit964ec62d4fbcc1fb2336a3de355ce3554ef7eb04 (patch)
tree04ae6f260d3345772a86849b6f969a9d87e959c8 /stdlib/source/test
parentac419f9e94bc3b82cfb78c41e91b08b308a2ac71 (diff)
Now using eval to derive code for arbitrary types.
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/type/poly.lux2
-rw-r--r--stdlib/source/test/lux/type/poly/equivalence.lux14
-rw-r--r--stdlib/source/test/lux/type/poly/functor.lux27
-rw-r--r--stdlib/source/test/lux/type/poly/json.lux18
4 files changed, 39 insertions, 22 deletions
diff --git a/stdlib/source/test/lux/type/poly.lux b/stdlib/source/test/lux/type/poly.lux
index eb4efeb9c..996a86320 100644
--- a/stdlib/source/test/lux/type/poly.lux
+++ b/stdlib/source/test/lux/type/poly.lux
@@ -12,7 +12,7 @@
(def: .public test
Test
(<| (_.covering /._)
- (_.for [/.poly: /.derived: /.code])
+ (_.for [/.poly: /.code])
($_ _.and
/equivalence.test
/functor.test
diff --git a/stdlib/source/test/lux/type/poly/equivalence.lux b/stdlib/source/test/lux/type/poly/equivalence.lux
index ae73c44a7..5bfb8e39d 100644
--- a/stdlib/source/test/lux/type/poly/equivalence.lux
+++ b/stdlib/source/test/lux/type/poly/equivalence.lux
@@ -2,6 +2,7 @@
[library
[lux {"-" [Variant Record]}
["_" test {"+" [Test]}]
+ ["@" target]
[abstract
[monad {"+" [do]}]
[equivalence {"+" [Equivalence]}
@@ -20,9 +21,7 @@
["[0]" random {"+" [Random]}]
[number
["n" nat]
- ["i" int]]]
- [type
- [poly {"+" [derived:]}]]]])
+ ["i" int]]]]])
(type: Variant
(.Variant
@@ -77,11 +76,14 @@
(random.unicode size))
gen_recursive)))
-(derived: equivalence
- (/.equivalence ..Record))
+(for {@.old (as_is)}
+ (as_is (def: equivalence
+ (Equivalence ..Record)
+ (/.equivalence ..Record))))
(def: .public test
Test
(<| (_.covering /._)
(_.for [/.equivalence]
- ($equivalence.spec ..equivalence ..random))))
+ (for {@.old (_.test "PLACEHOLDER" true)}
+ ($equivalence.spec ..equivalence ..random)))))
diff --git a/stdlib/source/test/lux/type/poly/functor.lux b/stdlib/source/test/lux/type/poly/functor.lux
index e2cd1ad21..d9892b02c 100644
--- a/stdlib/source/test/lux/type/poly/functor.lux
+++ b/stdlib/source/test/lux/type/poly/functor.lux
@@ -1,9 +1,10 @@
(.module:
[library
[lux "*"
+ ["@" target]
[abstract
[monad {"+" [do]}]
- [functor
+ [functor {"+" [Functor]}
[\\poly
["[0]" /]]]]
["r" math/random {"+" [Random]}]
@@ -11,14 +12,24 @@
[control
["[0]" state]]
[data
- ["[0]" identity]]
- [type
- [poly {"+" [derived:]}]]]])
+ ["[0]" identity]]]])
-(derived: maybe_functor (/.functor .Maybe))
-(derived: list_functor (/.functor .List))
-(derived: state_functor (/.functor state.State))
-(derived: identity_functor (/.functor identity.Identity))
+(for {@.old (as_is)}
+ (as_is (def: maybe_functor
+ (Functor .Maybe)
+ (/.functor .Maybe))
+
+ (def: list_functor
+ (Functor .List)
+ (/.functor .List))
+
+ (def: state_functor
+ (All (_ s) (Functor (state.State s)))
+ (/.functor state.State))
+
+ (def: identity_functor
+ (Functor identity.Identity)
+ (/.functor identity.Identity))))
(def: .public test
Test
diff --git a/stdlib/source/test/lux/type/poly/json.lux b/stdlib/source/test/lux/type/poly/json.lux
index 6abaa47f1..259a25b95 100644
--- a/stdlib/source/test/lux/type/poly/json.lux
+++ b/stdlib/source/test/lux/type/poly/json.lux
@@ -2,6 +2,7 @@
[library
[lux {"-" [Variant Record]}
["_" test {"+" [Test]}]
+ ["@" target]
["[0]" debug]
[abstract
codec
@@ -21,7 +22,7 @@
["[0]" bit]
["[0]" text]
[format
- [json {"+" []}
+ [json {"+" [JSON]}
[\\poly
["[0]" /]]]]
[collection
@@ -29,7 +30,6 @@
["d" dictionary]
["[0]" list]]]
[type
- [poly {"+" [derived:]}]
["[0]" unit]]
[math
["[0]" random {"+" [Random]}]
@@ -108,14 +108,18 @@
..qty
)))
-(derived: equivalence
- (poly/equivalence.equivalence Record))
+(for {@.old (as_is)}
+ (as_is (def: equivalence
+ (Equivalence Record)
+ (poly/equivalence.equivalence Record))
-(derived: codec
- (/.codec Record))
+ (def: codec
+ (Codec JSON Record)
+ (/.codec Record))))
(def: .public test
Test
(<| (_.covering /._)
(_.for [/.codec]
- ($codec.spec ..equivalence ..codec ..gen_record))))
+ (for {@.old (_.test "PLACEHOLDER" true)}
+ ($codec.spec ..equivalence ..codec ..gen_record)))))