From c03bd9f9787fb9f383c57b4ebb0fa9d49abbfaa1 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 3 Jan 2021 07:48:12 -0400 Subject: Place the "program:" macro of "lux/control/parser/cli" in its own module. --- stdlib/source/test/lux/macro/code.lux | 1 + stdlib/source/test/lux/macro/poly/equivalence.lux | 16 +++++----- stdlib/source/test/lux/macro/poly/functor.lux | 6 ++-- stdlib/source/test/lux/macro/syntax/common.lux | 17 +++------- .../test/lux/macro/syntax/common/annotations.lux | 3 +- .../test/lux/macro/syntax/common/type/variable.lux | 37 ++++++++++++++++++++++ 6 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 stdlib/source/test/lux/macro/syntax/common/type/variable.lux (limited to 'stdlib/source/test/lux/macro') diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index 1244b84e4..0f217e335 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -119,6 +119,7 @@ ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) + (_.for [/.format] (`` ($_ _.and (~~ (template [ ] diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index c1edf6022..593dba8e1 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -6,7 +6,10 @@ [monad (#+ do)] [equivalence (#+ Equivalence) {[0 #poly] - ["." /]}]] + ["." /]}] + {[0 #spec] + [/ + ["$." equivalence]]}] [data ["." bit] ["." maybe] @@ -48,7 +51,7 @@ (random.and random.safe_frac gen_recursive))))) -(def: gen_record +(def: random (Random Record) (do {! random.monad} [size (\ ! map (n.% 2) random.nat) @@ -75,9 +78,6 @@ (def: #export test Test - (<| (_.context (%.name (name_of /._))) - (do random.monad - [sample gen_record - #let [(^open "/\.") ..equivalence]] - (_.test "Every instance equals itself." - (/\= sample sample))))) + (<| (_.covering /._) + (_.for [/.equivalence] + ($equivalence.spec ..equivalence ..random)))) diff --git a/stdlib/source/test/lux/macro/poly/functor.lux b/stdlib/source/test/lux/macro/poly/functor.lux index 3f2b4db50..9463d7f11 100644 --- a/stdlib/source/test/lux/macro/poly/functor.lux +++ b/stdlib/source/test/lux/macro/poly/functor.lux @@ -22,6 +22,6 @@ (def: #export test Test - (<| (_.context (%.name (name_of /._))) - (_.test "Can derive functors automatically." - true))) + (<| (_.covering /._) + (_.cover [/.functor] + true))) diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux index 429b7fc6e..2929417e3 100644 --- a/stdlib/source/test/lux/macro/syntax/common.lux +++ b/stdlib/source/test/lux/macro/syntax/common.lux @@ -33,7 +33,9 @@ ["#." check] ["#." declaration] ["#." definition] - ["#." export]]) + ["#." export] + ["#." type #_ + ["#/." variable]]]) (def: random_text (Random Text) @@ -45,18 +47,6 @@ (_.covering /reader._) (_.covering /writer._) ($_ _.and - (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 - (.run /reader.type_variables) - (case> (#try.Success actual) - (\ (list.equivalence text.equivalence) = expected actual) - - (#try.Failure error) - false)))) (do {! random.monad} [expected (: (Random /.Typed_Input) (random.and ///code.random @@ -77,4 +67,5 @@ /declaration.test /definition.test /export.test + /type/variable.test ))) diff --git a/stdlib/source/test/lux/macro/syntax/common/annotations.lux b/stdlib/source/test/lux/macro/syntax/common/annotations.lux index bc29a00f6..b1369ef48 100644 --- a/stdlib/source/test/lux/macro/syntax/common/annotations.lux +++ b/stdlib/source/test/lux/macro/syntax/common/annotations.lux @@ -49,4 +49,5 @@ false (#try.Success actual) - (\ /.equivalence = expected actual))))))) + (\ /.equivalence = expected actual)))) + ))) diff --git a/stdlib/source/test/lux/macro/syntax/common/type/variable.lux b/stdlib/source/test/lux/macro/syntax/common/type/variable.lux new file mode 100644 index 000000000..4701f5aef --- /dev/null +++ b/stdlib/source/test/lux/macro/syntax/common/type/variable.lux @@ -0,0 +1,37 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence]]}] + [control + ["." try ("#\." functor)] + [parser + ["<.>" code]]] + [math + ["." random (#+ Random)]]] + {1 + ["." /]}) + +(def: #export random + (Random /.Variable) + (random.ascii/alpha 10)) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [/.Variable]) + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + + (do random.monad + [expected ..random] + (_.cover [/.format /.parser] + (|> (list (/.format expected)) + (.run /.parser) + (try\map (\ /.equivalence = expected)) + (try.default false)))) + ))) -- cgit v1.2.3