From e814f667aed509a70bd386dcd54628929134def4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 26 Aug 2021 02:34:05 -0400 Subject: "Interface" instead of "interface:", and "Rec" can be used in type definition. --- stdlib/source/test/lux.lux | 20 +++++++++++++---- .../source/test/lux/control/function/contract.lux | 17 ++++++++++----- stdlib/source/test/lux/control/security/policy.lux | 15 +++++++------ stdlib/source/test/lux/math/number/frac.lux | 18 ++++++++-------- stdlib/source/test/lux/math/number/rev.lux | 1 + stdlib/source/test/lux/meta/annotation.lux | 25 +++++++++------------- stdlib/source/test/lux/type/poly/equivalence.lux | 11 +++++----- stdlib/source/test/lux/type/poly/json.lux | 9 ++++---- 8 files changed, 67 insertions(+), 49 deletions(-) (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index a072fbc25..df0eb2f09 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -227,9 +227,10 @@ false)) ))) -(/.interface: (Returner a) - (: (-> Any a) - return)) +(type: (Returner a) + (/.Interface + (: (-> Any a) + return))) (/.implementation: (global_returner value) (All [a] (-> a (Returner a))) @@ -249,7 +250,7 @@ (/.implementation (def: (return _) expected)))]] - (_.for [/.interface:] + (_.for [/.Interface] ($_ _.and (_.cover [/.implementation:] (n.= expected (\ (global_returner expected) return []))) @@ -557,6 +558,17 @@ (: /.Type ..for_type/record) (: /.Type ..for_type/all) true)) + (_.cover [/.Variant] + (exec + (: for_type/variant + (#Case/1 expected_left)) + true)) + (_.cover [/.Record] + (exec + (: for_type/record + {#slot/0 (n.= expected_left expected_right) + #slot/1 (.rev expected_right)}) + true)) )))) (def: for_i64 diff --git a/stdlib/source/test/lux/control/function/contract.lux b/stdlib/source/test/lux/control/function/contract.lux index 48246a7c2..0cc1612d2 100644 --- a/stdlib/source/test/lux/control/function/contract.lux +++ b/stdlib/source/test/lux/control/function/contract.lux @@ -5,7 +5,10 @@ [abstract [monad (#+ do)]] [control - ["." try]] + ["." try] + ["." exception]] + [data + ["." text]] [math ["." random] [number @@ -19,20 +22,24 @@ (do {! random.monad} [expected random.nat]) ($_ _.and - (_.cover [/.pre] + (_.cover [/.pre /.pre_condition_failed] (case (try (/.pre (n.even? expected) true)) (#try.Success output) output (#try.Failure error) - (not (n.even? expected)))) - (_.cover [/.post] + (and (text.contains? (value@ #exception.label /.pre_condition_failed) + error) + (not (n.even? expected))))) + (_.cover [/.post /.post_condition_failed] (case (try (/.post n.odd? expected)) (#try.Success actual) (same? expected actual) (#try.Failure error) - (not (n.odd? expected)))) + (and (text.contains? (value@ #exception.label /.post_condition_failed) + error) + (not (n.odd? expected))))) ))) diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index 5c2f1bf67..b49d04df9 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -33,15 +33,16 @@ (type: Password (Private Text)) -(interface: (Policy %) - (: (Hash (Password %)) - &hash) +(type: (Policy %) + (Interface + (: (Hash (Password %)) + &hash) - (: (-> Text (Password %)) - password) + (: (-> Text (Password %)) + password) - (: (Privilege Privacy %) - privilege)) + (: (Privilege Privacy %) + privilege))) (def: (policy _) (Ex [%] (-> Any (Policy %))) diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index 7b11df2cb..cb8d4abaa 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -175,15 +175,15 @@ (and (/.= div (/./ left right)) (/.= rem (/.% left right))))) (_.cover [/.mod] - (and (/.= (/.signum left) - (/.signum (/.mod left right))) - (/.= (/.signum right) - (/.signum (/.% left right))) - (if (/.= (/.signum left) (/.signum right)) - (/.= (/.% left right) - (/.mod left right)) - (or (and (/.= +0.0 (/.% left right)) - (/.= +0.0 (/.mod left right))) + (or (and (/.= +0.0 (/.% left right)) + (/.= +0.0 (/.mod left right))) + (and (/.= (/.signum left) + (/.signum (/.mod left right))) + (/.= (/.signum right) + (/.signum (/.% left right))) + (if (/.= (/.signum left) (/.signum right)) + (/.= (/.% left right) + (/.mod left right)) (/.= (/.+ left (/.% left right)) (/.mod left right)))))) )) diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index cde50ec02..e55b08222 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -63,6 +63,7 @@ (/.= (/.+ )))] + [/./1 (-- /./1)] [/./2 .0] [/./4 /./2] [/./8 /./4] diff --git a/stdlib/source/test/lux/meta/annotation.lux b/stdlib/source/test/lux/meta/annotation.lux index f80ffeb29..c9a0f6946 100644 --- a/stdlib/source/test/lux/meta/annotation.lux +++ b/stdlib/source/test/lux/meta/annotation.lux @@ -101,21 +101,16 @@ (not (|> expected code.bit (..annotation dummy) (/.flagged? key)))))) - (~~ (template [ ] - [(do ! - [expected random.bit] - (_.cover [] - (and (|> expected code.bit - (..annotation (name_of )) - - (\ bit.equivalence = expected)) - (not (|> expected code.bit - (..annotation key) - )))))] - - [/.implementation? #.implementation?] - [/.recursive_type? #.type_rec?] - )) + (do ! + [expected random.bit] + (_.cover [/.implementation?] + (and (|> expected code.bit + (..annotation (name_of #.implementation?)) + /.implementation? + (\ bit.equivalence = expected)) + (not (|> expected code.bit + (..annotation key) + /.implementation?))))) )))) (def: arguments diff --git a/stdlib/source/test/lux/type/poly/equivalence.lux b/stdlib/source/test/lux/type/poly/equivalence.lux index 5d1953a52..a66c390b3 100644 --- a/stdlib/source/test/lux/type/poly/equivalence.lux +++ b/stdlib/source/test/lux/type/poly/equivalence.lux @@ -30,10 +30,11 @@ (#Case1 Int) (#Case2 Frac))) -(type: #rec Recursive - (.Variant - (#Number Frac) - (#Addition Frac Recursive))) +(type: Recursive + (Rec Recursive + (.Variant + (#Number Frac) + (#Addition Frac Recursive)))) (type: Record (.Record @@ -77,7 +78,7 @@ gen_recursive))) (derived: equivalence - (/.equivalence Record)) + (/.equivalence ..Record)) (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 8e09a998a..2a7c17814 100644 --- a/stdlib/source/test/lux/type/poly/json.lux +++ b/stdlib/source/test/lux/type/poly/json.lux @@ -54,10 +54,11 @@ (#Text Text) (#Frac Frac))) -(type: #rec Recursive - (.Variant - (#Number Frac) - (#Addition Frac Recursive))) +(type: Recursive + (Rec Recursive + (.Variant + (#Number Frac) + (#Addition Frac Recursive)))) (type: Record (.Record -- cgit v1.2.3