From 3ca054b6b992e2233d763aabc5c938ee10d116a4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 4 Jan 2023 18:37:14 -0400 Subject: Added simple machinery for aliasing of definitions. --- stdlib/source/library/lux.lux | 30 ++++-- stdlib/source/library/lux/math/number/ratio.lux | 20 ++-- .../meta/compiler/language/lux/analysis/module.lux | 37 ++++--- .../lux/phase/extension/translation/jvm/host.lux | 2 +- .../library/lux/meta/compiler/meta/packager.lux | 10 +- .../source/library/lux/meta/compiler/version.lux | 12 ++- stdlib/source/library/lux/test/benchmark.lux | 13 ++- stdlib/source/library/lux/web/css/value.lux | 2 +- .../library/lux/world/finance/market/price.lux | 25 +++-- stdlib/source/specification/lux/abstract/hash.lux | 29 ----- .../source/specification/lux/math/arithmetic.lux | 57 ---------- stdlib/source/test/aedifex/artifact.lux | 6 +- stdlib/source/test/aedifex/dependency.lux | 6 +- stdlib/source/test/lux/abstract/hash.lux | 20 +++- stdlib/source/test/lux/control/maybe.lux | 6 +- stdlib/source/test/lux/data/any.lux | 6 +- stdlib/source/test/lux/data/bit.lux | 6 +- stdlib/source/test/lux/data/collection/list.lux | 6 +- stdlib/source/test/lux/data/collection/set.lux | 6 +- .../source/test/lux/data/collection/set/multi.lux | 6 +- stdlib/source/test/lux/data/color/rgb.lux | 6 +- stdlib/source/test/lux/data/sum.lux | 6 +- stdlib/source/test/lux/data/text.lux | 6 +- stdlib/source/test/lux/data/text/unicode/block.lux | 6 +- stdlib/source/test/lux/math/arithmetic.lux | 57 ++++++++++ .../test/lux/math/arithmetic/fixed_point.lux | 4 +- stdlib/source/test/lux/math/number/complex.lux | 4 +- stdlib/source/test/lux/math/number/frac.lux | 10 +- stdlib/source/test/lux/math/number/i64.lux | 6 +- stdlib/source/test/lux/math/number/int.lux | 10 +- stdlib/source/test/lux/math/number/nat.lux | 10 +- stdlib/source/test/lux/math/number/ratio.lux | 4 +- stdlib/source/test/lux/math/number/rev.lux | 10 +- stdlib/source/test/lux/meta.lux | 32 +++--- stdlib/source/test/lux/meta/compiler.lux | 5 +- .../compiler/language/lux/analysis/complex.lux | 6 +- .../meta/compiler/language/lux/phase/extension.lux | 6 +- .../language/lux/synthesis/access/member.lux | 6 +- .../language/lux/synthesis/access/side.lux | 6 +- .../compiler/language/lux/synthesis/simple.lux | 6 +- stdlib/source/test/lux/meta/compiler/meta.lux | 32 ++++++ .../source/test/lux/meta/compiler/meta/archive.lux | 79 +++++++------- .../compiler/meta/archive/artifact/category.lux | 4 - .../lux/meta/compiler/meta/archive/registry.lux | 62 ++++------- .../test/lux/meta/compiler/meta/archive/unit.lux | 6 +- stdlib/source/test/lux/meta/compiler/reference.lux | 6 +- .../test/lux/meta/compiler/reference/variable.lux | 6 +- stdlib/source/test/lux/meta/macro/syntax/check.lux | 3 +- stdlib/source/test/lux/meta/symbol.lux | 6 +- stdlib/source/test/lux/meta/target/jvm.lux | 120 ++++++++++----------- stdlib/source/test/lux/meta/target/lua.lux | 6 +- stdlib/source/test/lux/meta/target/python.lux | 6 +- stdlib/source/test/lux/test/benchmark.lux | 27 +++-- .../source/test/lux/world/finance/market/price.lux | 106 +++++++++--------- stdlib/source/test/lux/world/locale.lux | 10 +- stdlib/source/test/lux/world/locale/language.lux | 6 +- stdlib/source/test/lux/world/locale/territory.lux | 6 +- stdlib/source/test/lux/world/net/http/version.lux | 6 +- stdlib/source/test/lux/world/net/mime.lux | 6 +- stdlib/source/test/lux/world/net/uri/scheme.lux | 6 +- .../test/lux/world/output/video/resolution.lux | 6 +- stdlib/source/test/lux/world/time/day.lux | 6 +- stdlib/source/test/lux/world/time/instant.lux | 6 +- stdlib/source/test/lux/world/time/month.lux | 6 +- 64 files changed, 541 insertions(+), 503 deletions(-) delete mode 100644 stdlib/source/specification/lux/abstract/hash.lux delete mode 100644 stdlib/source/specification/lux/math/arithmetic.lux create mode 100644 stdlib/source/test/lux/math/arithmetic.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta.lux (limited to 'stdlib/source') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 763b1b25f..e6108721f 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -3292,7 +3292,7 @@ _ ... TODO: Figure out why this doesn't work: - ... (of meta#monad in token) + ... (meta#in token) (meta#in token)} token)))) @@ -5479,14 +5479,15 @@ (again &rest (property#with var_name expansion map))) {#End} - (of meta#monad #in (list#conjoint (list#each normal bodies)))))) + (meta#in (list#conjoint (list#each normal bodies)))))) {#None} (failure (..wrong_syntax_error (symbol ..with_expansions))))))) (def .public (same? reference sample) - (All (_ a) - (-> a a Bit)) + (All (_ of) + (-> of of + Bit)) (.is?# reference sample)) (def .public as_expected @@ -5878,5 +5879,22 @@ [Declaration] ) -(type .public F64 Frac) -(type .public Double Frac) +(def .public alias + (macro (_ tokens) + (when (parsed (andP (tupleP (manyP localP)) + symbolP) + tokens) + {#Some [alias/+ original]} + (meta#in (list#each (function (_ it) + (` (def .public (, (local$ it)) + (, (symbol$ original))))) + alias/+)) + + {#None} + (failure (..wrong_syntax_error (symbol ..alias)))))) + +(alias [F64 Double] + ..Frac) + +(alias [alias?] + ..same?) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 4877d65da..d1a8cc3a6 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -37,12 +37,12 @@ 1 {.#Some (the #numerator value)} _ {.#None})) -(def .public (normal (open "_[0]")) +(def .public (normal (open "/[0]")) (-> Ratio Ratio) - (let [common (n.gcd _#numerator _#denominator)] - [..#numerator (n./ common _#numerator) - ..#denominator (n./ common _#denominator)])) + (let [common (n.gcd /#numerator /#denominator)] + [..#numerator (n./ common /#numerator) + ..#denominator (n./ common /#denominator)])) (def .public ratio (syntax (_ [numerator .any @@ -146,21 +146,21 @@ (def * ..*) (def / ../))) -(def .public (reciprocal (open "_[0]")) +(def .public (reciprocal (open "/[0]")) (-> Ratio Ratio) - [..#numerator _#denominator - ..#denominator _#numerator]) + [..#numerator /#denominator + ..#denominator /#numerator]) (def separator ":") (def .public codec (Codec Text Ratio) (implementation - (def (encoded (open "_[0]")) + (def (encoded (open "/[0]")) (all text#composite - (n#encoded _#numerator) - ..separator (n#encoded _#denominator))) + (n#encoded /#numerator) + ..separator (n#encoded /#denominator))) (def (decoded input) (when (text.split_by ..separator input) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux index 29dad85d1..f5f9a5ecb 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except with) + [lux (.except with alias) ["[0]" meta] [abstract ["[0]" monad (.only do)]] @@ -47,7 +47,8 @@ {.#Cached} "Cached")]))) (def .public (empty hash) - (-> Nat Module) + (-> Nat + Module) [.#module_hash hash .#module_aliases (list) .#definitions (list) @@ -55,7 +56,8 @@ .#module_state {.#Active}]) (def .public (import module) - (-> Text (Operation Any)) + (-> Text + (Operation Any)) (do phase.monad [self_name meta.current_module_name] (function (_ state) @@ -68,19 +70,21 @@ state) []]}))) -(def .public (alias alias module) - (-> Text Text (Operation Any)) +(def .public (alias it module) + (-> Text Text + (Operation Any)) (do phase.monad [self_name meta.current_module_name] (function (_ state) {try.#Success [(revised .#modules (property.revised self_name (revised .#module_aliases (is (-> (List [Text Text]) (List [Text Text])) - (|>> {.#Item [alias module]})))) + (|>> {.#Item [it module]})))) state) []]}))) (def .public (exists? module) - (-> Text (Operation Bit)) + (-> Text + (Operation Bit)) (function (_ state) (|> state (the .#modules) @@ -95,7 +99,8 @@ {try.#Success}))) (def .public (define name exported?,definition) - (-> Text [Bit Global] (Operation Any)) + (-> Text [Bit Global] + (Operation Any)) (do phase.monad [self_name meta.current_module_name self meta.current_module] @@ -117,7 +122,8 @@ state))))) (def .public (override_definition [module short] exported?,definition) - (-> Symbol [Bit Global] (Operation Any)) + (-> Symbol [Bit Global] + (Operation Any)) (function (_ state) {try.#Success [(revised .#modules (property.revised module @@ -127,7 +133,8 @@ []]})) (def .public (create hash name) - (-> Nat Text (Operation Any)) + (-> Nat Text + (Operation Any)) (function (_ state) {try.#Success [(revised .#modules (property.has name (..empty hash)) @@ -135,7 +142,9 @@ []]})) (def .public (with hash name action) - (All (_ a) (-> Nat Text (Operation a) (Operation [Module a]))) + (All (_ of) + (-> Nat Text (Operation of) + (Operation [Module of]))) (do phase.monad [_ (..create hash name) output (/.with_current_module name @@ -145,7 +154,8 @@ (with_template [ ] [(def .public ( module_name) - (-> Text (Operation Any)) + (-> Text + (Operation Any)) (function (_ state) (when (|> state (the .#modules) (property.value module_name)) {.#Some module} @@ -168,7 +178,8 @@ state)))) (def .public ( module_name) - (-> Text (Operation Bit)) + (-> Text + (Operation Bit)) (function (_ state) (when (|> state (the .#modules) (property.value module_name)) {.#Some module} diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux index fb9ee9327..522cf231b 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux @@ -318,7 +318,7 @@ (def with_double_extensions (-> Bundle Bundle) - (let [type (reflection.reflection reflection.float)] + (let [type (reflection.reflection reflection.double)] (|>> (dictionary.has (%.format "jvm_" type "_" "+" "#" "|translation") (binary double::+)) (dictionary.has (%.format "jvm_" type "_" "-" "#" "|translation") (binary double::-)) (dictionary.has (%.format "jvm_" type "_" "*" "#" "|translation") (binary double::*)) diff --git a/stdlib/source/library/lux/meta/compiler/meta/packager.lux b/stdlib/source/library/lux/meta/compiler/meta/packager.lux index a7e8a095c..68edb9e16 100644 --- a/stdlib/source/library/lux/meta/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/meta/compiler/meta/packager.lux @@ -20,13 +20,10 @@ ["[0]" artifact] ["[0]" registry] ["[0]" unit] - ["[0]" module (.only) - ["[0]" descriptor]]]]) + ["[0]" module]]]) (type .public Packager - (-> (Dictionary file.Path Binary) - Archive - (Maybe unit.ID) + (-> (Dictionary file.Path Binary) Archive (Maybe unit.ID) (Try (Either Binary (List [Text Binary]))))) @@ -34,7 +31,8 @@ (List [module.ID (List artifact.ID)])) (def .public order - (-> (cache/module.Order Any) Order) + (-> (cache/module.Order Any) + Order) (list#each (function (_ [module [module_id entry]]) (|> entry (the archive.#registry) diff --git a/stdlib/source/library/lux/meta/compiler/version.lux b/stdlib/source/library/lux/meta/compiler/version.lux index e576a7c29..ece4e5098 100644 --- a/stdlib/source/library/lux/meta/compiler/version.lux +++ b/stdlib/source/library/lux/meta/compiler/version.lux @@ -21,22 +21,26 @@ (n./ ..range)) (def .public patch - (-> Version Nat) + (-> Version + Nat) (|>> ..level)) (def .public minor - (-> Version Nat) + (-> Version + Nat) (|>> ..next ..level)) (def .public major - (-> Version Nat) + (-> Version + Nat) (|>> ..next ..next)) (def separator ".") (def (padded value) - (-> Nat Text) + (-> Nat + Text) (if (n.< 10 value) (%.format "0" (%.nat value)) (%.nat value))) diff --git a/stdlib/source/library/lux/test/benchmark.lux b/stdlib/source/library/lux/test/benchmark.lux index 427e62822..f25975015 100644 --- a/stdlib/source/library/lux/test/benchmark.lux +++ b/stdlib/source/library/lux/test/benchmark.lux @@ -9,6 +9,9 @@ [data [collection ["[0]" list (.use "[1]#[0]" mix)]]] + [math + [number + ["[0]" int]]] [world [time ["[0]" instant] @@ -30,6 +33,12 @@ #maximum Duration #average Duration])) +(def minimum_duration + duration.empty) + +(def maximum_duration + (duration.of_millis (of int.interval top))) + (def empty Benchmark [#times 0 @@ -47,8 +56,8 @@ (list.repeated times) (monad.each ! ..time))] (in [#times times - #minimum (list#mix (order.min duration.order) duration.empty durations) - #maximum (list#mix (order.max duration.order) duration.empty durations) + #minimum (list#mix (order.min duration.order) ..maximum_duration durations) + #maximum (list#mix (order.max duration.order) ..minimum_duration durations) #average (|> durations (list#mix duration.composite duration.empty) (duration.down times))])))) diff --git a/stdlib/source/library/lux/web/css/value.lux b/stdlib/source/library/lux/web/css/value.lux index 2ff369bc7..31e19b316 100644 --- a/stdlib/source/library/lux/web/css/value.lux +++ b/stdlib/source/library/lux/web/css/value.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except Label All Location and static false true all) + [lux (.except Label All Location and static false true all alias) [control ["[0]" maybe]] [data diff --git a/stdlib/source/library/lux/world/finance/market/price.lux b/stdlib/source/library/lux/world/finance/market/price.lux index 58c4216d8..c7b6e8e8c 100644 --- a/stdlib/source/library/lux/world/finance/market/price.lux +++ b/stdlib/source/library/lux/world/finance/market/price.lux @@ -9,39 +9,48 @@ ["%" \\format]]] [math [number + ["n" nat] ["i" int]]] [meta [type ["[0]" nominal]]]]] [/// - [money (.only Money) + ["[0]" money (.only Money) ["[0]" currency (.only Currency)]]]) (type .public (Price $) (Money $)) +(def .public (free $) + (All (_ $) + (-> (Currency $) + (Price $))) + (money.money $ 0)) + ... https://en.wikipedia.org/wiki/Price_action_trading (nominal.def .public (Action $) (Record [#currency (Currency $) #movement Int]) - (def .public (action currency movement) + (def .public (action from to) (All (_ $) - (-> (Currency $) Int + (-> (Price $) (Price $) (Action $))) (nominal.abstraction - [#currency currency - #movement movement])) + [#currency (money.currency from) + #movement (.int (n.- (money.amount from) + (money.amount to)))])) (with_template [<*> ] [(def .public ( currency it) (All (_ $) (-> (Currency $) Int (Action $))) - (action currency - (<*> (.int (currency.sub_divisions currency)) - it)))] + (nominal.abstraction + [#currency currency + #movement (<*> (.int (currency.sub_divisions currency)) + it)]))] [i.* of_units] [i.% of_sub_units] diff --git a/stdlib/source/specification/lux/abstract/hash.lux b/stdlib/source/specification/lux/abstract/hash.lux deleted file mode 100644 index 28b1c27a2..000000000 --- a/stdlib/source/specification/lux/abstract/hash.lux +++ /dev/null @@ -1,29 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [monad (.only do)] - ["[0]" equivalence - ["[1]T" \\test]]] - [math - ["[0]" random (.only Random)] - [number - ["n" nat]]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" /]]) - -(def .public (spec (open "/#[0]") random) - (All (_ a) (-> (/.Hash a) (Random a) Test)) - (do random.monad - [parameter random - subject random] - (all _.and - (_.for [/.equivalence] - (equivalenceT.spec /#equivalence random)) - (_.coverage [/.Hash /.hash] - (if (/#= parameter subject) - (n.= (/#hash parameter) (/#hash subject)) - true)) - ))) diff --git a/stdlib/source/specification/lux/math/arithmetic.lux b/stdlib/source/specification/lux/math/arithmetic.lux deleted file mode 100644 index 1c13f52f5..000000000 --- a/stdlib/source/specification/lux/math/arithmetic.lux +++ /dev/null @@ -1,57 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [equivalence (.only Equivalence)] - [monad (.only do)]] - [math - ["[0]" random (.only Random)]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" /]]) - -(def .public (spec (open "[0]") (open "[0]") random) - (All (_ of) - (-> (Equivalence of) (/.Arithmetic of) (Random of) - Test)) - (do random.monad - [any random - .let [@0 (- any any) - non_zero (random.only (|>> (= @0) not) - random)] - any non_zero - .let [@1 (/ any any) - @2 (+ @1 @1) - @4 (+ @2 @2) - @8 (+ @4 @4) - - power_of_two (all random.either - (in @1) - (in @2) - (in @4) - (in @8) - )] - left power_of_two - right power_of_two] - (<| (_.covering /._) - (_.for [/.Arithmetic]) - (all _.and - (_.coverage [/.+ /.-] - (and (|> left (+ right) (- right) (= left)) - (|> left (- right) (+ right) (= left)) - - (|> left (+ @0) (= left)) - (|> left (- @0) (= left)) - - (|> left (- left) (= @0)))) - (_.coverage [/.* /./] - (and (|> left (* @0) (= @0)) - - (|> left (* @1) (= left)) - (|> left (/ @1) (= left)) - - (|> left (/ left) (= @1)) - - (|> left (* @2) (/ @2) (= left)))) - )))) diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux index 471786919..7e0d2c1cb 100644 --- a/stdlib/source/test/aedifex/artifact.lux +++ b/stdlib/source/test/aedifex/artifact.lux @@ -4,8 +4,8 @@ [abstract [monad (.only do)] [hash (.only Hash)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]] ["[0]" order @@ -50,7 +50,7 @@ (_.for [/.order] (orderT.spec /.order ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.format /.identity] (and (text.ends_with? (/.identity sample) (/.format sample)) diff --git a/stdlib/source/test/aedifex/dependency.lux b/stdlib/source/test/aedifex/dependency.lux index 6235282ee..02721cf35 100644 --- a/stdlib/source/test/aedifex/dependency.lux +++ b/stdlib/source/test/aedifex/dependency.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]] ["[0]" order @@ -34,5 +34,5 @@ (_.for [/.order] (orderT.spec /.order ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) )))) diff --git a/stdlib/source/test/lux/abstract/hash.lux b/stdlib/source/test/lux/abstract/hash.lux index fb6bf8925..51c8ec7f3 100644 --- a/stdlib/source/test/lux/abstract/hash.lux +++ b/stdlib/source/test/lux/abstract/hash.lux @@ -3,13 +3,15 @@ [lux (.except) [abstract [monad (.only do)] + ["[0]" equivalence + ["[1]T" \\test]] [functor ["[0]" contravariant ["[1]T" \\test]]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)]] [math - ["[0]" random] + ["[0]" random (.only Random)] [number ["[0]" nat]]] [test @@ -19,6 +21,22 @@ [// [equivalence (.only Equivalence)]]]]) +(def .public (spec (open "/#[0]") random) + (All (_ of) + (-> (/.Hash of) (Random of) + Test)) + (do random.monad + [parameter random + subject random] + (all _.and + (_.for [/.equivalence] + (equivalenceT.spec /#equivalence random)) + (_.coverage [/.Hash /.hash] + (if (/#= parameter subject) + (nat.= (/#hash parameter) (/#hash subject)) + true)) + ))) + (def .public test Test (do random.monad diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index a9b64e197..b9f6c89df 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -8,8 +8,8 @@ ["[1]T" \\test]] ["[0]" apply ["[1]T" \\test]] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" monoid ["[1]T" \\test]] ["[0]" equivalence @@ -41,7 +41,7 @@ (_.for [/.hash] (|> random.nat (of random.monad each (|>> {.#Some})) - ($hash.spec (/.hash n.hash)))) + (hashT.spec (/.hash n.hash)))) (_.for [/.monoid] (monoidT.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat))) (_.for [/.functor] diff --git a/stdlib/source/test/lux/data/any.lux b/stdlib/source/test/lux/data/any.lux index da1b7dc55..91fc7aa41 100644 --- a/stdlib/source/test/lux/data/any.lux +++ b/stdlib/source/test/lux/data/any.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["[0]S" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)]] [test @@ -27,7 +27,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - (hashS.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.any] (same? [] /.any)) diff --git a/stdlib/source/test/lux/data/bit.lux b/stdlib/source/test/lux/data/bit.lux index 5b2ec3b02..b3484192e 100644 --- a/stdlib/source/test/lux/data/bit.lux +++ b/stdlib/source/test/lux/data/bit.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]] ["[0]" codec @@ -29,7 +29,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence random.bit)) (_.for [/.hash] - ($hash.spec /.hash random.bit)) + (hashT.spec /.hash random.bit)) (_.for [/.disjunction] (monoidT.spec /.equivalence /.disjunction random.bit)) (_.for [/.conjunction] diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index c9131d41a..8fc76c5a6 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -15,8 +15,8 @@ ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [control ["[0]" pipe] ["[0]" io] @@ -59,7 +59,7 @@ (_.for [/.hash] (|> random.nat (of random.monad each (|>> list)) - ($hash.spec (/.hash n.hash)))) + (hashT.spec (/.hash n.hash)))) (_.for [/.monoid] (monoidT.spec (/.equivalence n.equivalence) /.monoid ..random)) (_.for [/.mix] diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index 19b44b8bf..b802660bf 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -6,8 +6,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" monoid ["[1]T" \\test]]] [data @@ -40,7 +40,7 @@ (_.for [/.hash] (|> random.nat (of random.monad each (|>> list (/.of_list n.hash))) - ($hash.spec /.hash))) + (hashT.spec /.hash))) (_.for [/.monoid] (monoidT.spec /.equivalence (/.monoid n.hash) (random.set n.hash size random.nat))) diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index 981de69d6..024044804 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -6,8 +6,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [control [function ["[0]" predicate]]] @@ -51,7 +51,7 @@ (|> random.nat (of random.monad each (function (_ single) (/.has 1 single (/.empty n.hash)))) - ($hash.spec /.hash))) + (hashT.spec /.hash))) ))) (def composition diff --git a/stdlib/source/test/lux/data/color/rgb.lux b/stdlib/source/test/lux/data/color/rgb.lux index 089759e56..99233f6e7 100644 --- a/stdlib/source/test/lux/data/color/rgb.lux +++ b/stdlib/source/test/lux/data/color/rgb.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["[0]S" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" monoid ["[1]T" \\test]]] [control @@ -107,7 +107,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - (hashS.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.for [/.addition] (monoidT.spec /.equivalence /.addition ..random)) (_.for [/.subtraction] diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index 97699e4a7..783dcf2df 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [control ["[0]" pipe]] [data @@ -35,7 +35,7 @@ (equivalenceT.spec (/.equivalence n.equivalence n.equivalence) (random.or random.nat random.nat))) (_.for [/.hash] - ($hash.spec (/.hash n.hash n.hash) + (hashT.spec (/.hash n.hash n.hash) (random.or random.nat random.nat))) (_.coverage [/.left] diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 23d12ebe1..65f55ac01 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -4,8 +4,8 @@ [abstract [monad (.only do)] [equivalence (.only Equivalence)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] [functor ["[0]" contravariant ["[1]T" \\test]]] @@ -866,7 +866,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence (random.ascii 2))) (_.for [/.hash] - ($hash.spec /.hash (random.ascii 1))) + (hashT.spec /.hash (random.ascii 1))) (_.for [/.order] (orderT.spec /.order (random.ascii 2))) (_.for [/.monoid] diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index 88261f69a..dcd00dc56 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" monoid ["[1]T" \\test]]] [data @@ -190,7 +190,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.for [/.monoid] (monoidT.spec /.equivalence /.monoid ..random)) diff --git a/stdlib/source/test/lux/math/arithmetic.lux b/stdlib/source/test/lux/math/arithmetic.lux new file mode 100644 index 000000000..1c13f52f5 --- /dev/null +++ b/stdlib/source/test/lux/math/arithmetic.lux @@ -0,0 +1,57 @@ +(.require + [library + [lux (.except) + [abstract + [equivalence (.only Equivalence)] + [monad (.only do)]] + [math + ["[0]" random (.only Random)]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(def .public (spec (open "[0]") (open "[0]") random) + (All (_ of) + (-> (Equivalence of) (/.Arithmetic of) (Random of) + Test)) + (do random.monad + [any random + .let [@0 (- any any) + non_zero (random.only (|>> (= @0) not) + random)] + any non_zero + .let [@1 (/ any any) + @2 (+ @1 @1) + @4 (+ @2 @2) + @8 (+ @4 @4) + + power_of_two (all random.either + (in @1) + (in @2) + (in @4) + (in @8) + )] + left power_of_two + right power_of_two] + (<| (_.covering /._) + (_.for [/.Arithmetic]) + (all _.and + (_.coverage [/.+ /.-] + (and (|> left (+ right) (- right) (= left)) + (|> left (- right) (+ right) (= left)) + + (|> left (+ @0) (= left)) + (|> left (- @0) (= left)) + + (|> left (- left) (= @0)))) + (_.coverage [/.* /./] + (and (|> left (* @0) (= @0)) + + (|> left (* @1) (= left)) + (|> left (/ @1) (= left)) + + (|> left (/ left) (= @1)) + + (|> left (* @2) (/ @2) (= left)))) + )))) diff --git a/stdlib/source/test/lux/math/arithmetic/fixed_point.lux b/stdlib/source/test/lux/math/arithmetic/fixed_point.lux index a41078599..ddfe624b7 100644 --- a/stdlib/source/test/lux/math/arithmetic/fixed_point.lux +++ b/stdlib/source/test/lux/math/arithmetic/fixed_point.lux @@ -19,7 +19,7 @@ [number ["n" nat]] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [test ["_" property (.only Test)]]]] [\\library @@ -68,7 +68,7 @@ (_.for [/.order /.<] (orderT.spec (/.order @) (..random @))) ... (_.for [/.arithmetic] - ... (arithmeticS.spec (/.equivalence @) (/.arithmetic @) (..random @))) + ... (arithmeticT.spec (/.equivalence @) (/.arithmetic @) (..random @))) (_.coverage [/.fixed /.units /.sub_units] (/.= @ diff --git a/stdlib/source/test/lux/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux index b9a58dfcc..e449abc6f 100644 --- a/stdlib/source/test/lux/math/number/complex.lux +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -11,7 +11,7 @@ [math ["[0]" random (.only Random)] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [test ["_" property (.only Test)]]]] [\\library @@ -276,7 +276,7 @@ (_.for [/.= /.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.arithmetic] - (arithmeticS.spec /.equivalence /.arithmetic ..random)) + (arithmeticT.spec /.equivalence /.arithmetic ..random)) ..construction ..constant diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index d62c8b287..30fd2d64c 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -4,8 +4,8 @@ ["[0]" ffi] [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" equivalence @@ -19,7 +19,7 @@ [math ["[0]" random (.only Random)] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [meta ["@" target] [macro @@ -107,7 +107,7 @@ (_.for [/.equivalence /.=] (equivalenceT.spec /.equivalence random.safe_frac)) (_.for [/.hash] - ($hash.spec /.hash random.frac)) + (hashT.spec /.hash random.frac)) (_.for [/.order /.<] (orderT.spec /.order random.safe_frac)) (,, (with_template [ ] @@ -127,7 +127,7 @@ [/.binary] [/.octal] [/.decimal] [/.hex] )) (_.for [/.arithmetic] - (arithmeticS.spec /.equivalence /.arithmetic random.safe_frac)) + (arithmeticT.spec /.equivalence /.arithmetic random.safe_frac)) ))) (with_expansions [ (these (ffi.import java/lang/Double diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index 209a53fff..18cff8007 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -7,8 +7,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" monoid ["[1]T" \\test]]] [math @@ -155,7 +155,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence random.i64)) (_.for [/.hash] - ($hash.spec /.hash random.i64)) + (hashT.spec /.hash random.i64)) (_.for [/.disjunction] (monoidT.spec n.equivalence /.disjunction random.nat)) (_.for [/.conjunction] diff --git a/stdlib/source/test/lux/math/number/int.lux b/stdlib/source/test/lux/math/number/int.lux index dde18df95..99afb16d2 100644 --- a/stdlib/source/test/lux/math/number/int.lux +++ b/stdlib/source/test/lux/math/number/int.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" enum ["[1]T" \\test]] ["[0]" interval @@ -22,7 +22,7 @@ [math ["[0]" random (.only Random)] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [test ["_" property (.only Test)]]]] [\\library @@ -38,7 +38,7 @@ (_.for [/.equivalence /.=] (equivalenceT.spec /.equivalence random.int)) (_.for [/.hash] - ($hash.spec /.hash random.int)) + (hashT.spec /.hash random.int)) (_.for [/.order /.<] (orderT.spec /.order random.int)) (_.for [/.enum] @@ -62,7 +62,7 @@ [/.binary] [/.octal] [/.decimal] [/.hex] )) (_.for [/.arithmetic] - (arithmeticS.spec /.equivalence /.arithmetic random.int)) + (arithmeticT.spec /.equivalence /.arithmetic random.int)) ))) (def predicate diff --git a/stdlib/source/test/lux/math/number/nat.lux b/stdlib/source/test/lux/math/number/nat.lux index ecce84604..ffc99b37e 100644 --- a/stdlib/source/test/lux/math/number/nat.lux +++ b/stdlib/source/test/lux/math/number/nat.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" enum ["[1]T" \\test]] ["[0]" interval @@ -22,7 +22,7 @@ [math ["[0]" random] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [test ["_" property (.only Test)]]]] [\\library @@ -36,7 +36,7 @@ (_.for [/.equivalence /.=] (equivalenceT.spec /.equivalence random.nat)) (_.for [/.hash] - ($hash.spec /.hash random.nat)) + (hashT.spec /.hash random.nat)) (_.for [/.order /.<] (orderT.spec /.order random.nat)) (_.for [/.enum] @@ -60,7 +60,7 @@ [/.binary] [/.octal] [/.decimal] [/.hex] )) (_.for [/.arithmetic] - (arithmeticS.spec /.equivalence /.arithmetic random.nat)) + (arithmeticT.spec /.equivalence /.arithmetic random.nat)) ))) (def predicate diff --git a/stdlib/source/test/lux/math/number/ratio.lux b/stdlib/source/test/lux/math/number/ratio.lux index ecb92de4a..0c1e15bc3 100644 --- a/stdlib/source/test/lux/math/number/ratio.lux +++ b/stdlib/source/test/lux/math/number/ratio.lux @@ -18,7 +18,7 @@ [math ["[0]" random (.only Random)] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [test ["_" property (.only Test)]]]] [\\library @@ -59,7 +59,7 @@ (_.for [/.codec] (codecT.spec /.equivalence /.codec ..random)) (_.for [/.arithmetic] - (arithmeticS.spec /.equivalence /.arithmetic ..random)) + (arithmeticT.spec /.equivalence /.arithmetic ..random)) (do random.monad [.let [(open "#[0]") /.equivalence] diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index ce264cdef..65021aefb 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" enum ["[1]T" \\test]] ["[0]" interval @@ -22,7 +22,7 @@ [math ["[0]" random] ["[0]" arithmetic - ["[1]S" \\specification]]] + ["[1]T" \\test]]] [test ["_" property (.only Test)]]]] [\\library @@ -38,7 +38,7 @@ (_.for [/.equivalence /.=] (equivalenceT.spec /.equivalence random.rev)) (_.for [/.hash] - ($hash.spec /.hash random.rev)) + (hashT.spec /.hash random.rev)) (_.for [/.order /.<] (orderT.spec /.order random.rev)) (_.for [/.enum] @@ -61,7 +61,7 @@ [/.binary] [/.octal] [/.decimal] [/.hex] )) (_.for [/.arithmetic] - (arithmeticS.spec /.equivalence /.arithmetic random.rev)) + (arithmeticT.spec /.equivalence /.arithmetic random.rev)) ))) (def .public test diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 2dec361da..477d1e31e 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -46,18 +46,17 @@ ["[1][0]" static] ["[1][0]" extension] ["[1][0]" global] - ... ["[1][0]" target (.only) - ... (.,, (.for "{old}" (.,, (.these ["[1]/[0]" jvm])) - ... "JVM" (.,, (.these ["[1]/[0]" jvm])) - ... "JavaScript" (.,, (.these ["[1]/[0]" js])) - ... "Lua" (.,, (.these ["[1]/[0]" lua])) - ... "Python" (.,, (.these ["[1]/[0]" python])) - ... "Ruby" (.,, (.these ["[1]/[0]" ruby])) - ... (.,, (.these))))] + ["[1][0]" target (.only) + (.,, (.for "{old}" (.,, (.these ["[1]/[0]" jvm])) + "JVM" (.,, (.these ["[1]/[0]" jvm])) + "JavaScript" (.,, (.these ["[1]/[0]" js])) + "Lua" (.,, (.these ["[1]/[0]" lua])) + "Python" (.,, (.these ["[1]/[0]" python])) + "Ruby" (.,, (.these ["[1]/[0]" ruby])) + (.,, (.these))))] ["[1][0]" compiler ... ["[1]/[0]" phase] ... ["[1]/[0]" meta - ... ["[1]/[0]" archive] ... ["[1]/[0]" cli] ... ["[1]/[0]" export] ... ["[1]/[0]" import] @@ -1056,19 +1055,18 @@ /type.test /macro.test /static.test - ... /target.test - ... (,, (for @.jvm (,, (these /target/jvm.test)) - ... @.old (,, (these /target/jvm.test)) - ... @.js (,, (these /target/js.test)) - ... @.lua (,, (these /target/lua.test)) - ... @.python (,, (these /target/python.test)) - ... @.ruby (,, (these /target/ruby.test)))) + /target.test + (,, (for @.jvm (,, (these /target/jvm.test)) + @.old (,, (these /target/jvm.test)) + @.js (,, (these /target/js.test)) + @.lua (,, (these /target/lua.test)) + @.python (,, (these /target/python.test)) + @.ruby (,, (these /target/ruby.test)))) (,, (for @.old (,, (these)) (,, (these /extension.test)))) /global.test /compiler.test - ... /compiler/meta/archive.test ... /compiler/meta/cli.test ... /compiler/meta/export.test ... /compiler/meta/import.test diff --git a/stdlib/source/test/lux/meta/compiler.lux b/stdlib/source/test/lux/meta/compiler.lux index 30e4ce1d9..58ac3c8a3 100644 --- a/stdlib/source/test/lux/meta/compiler.lux +++ b/stdlib/source/test/lux/meta/compiler.lux @@ -15,8 +15,7 @@ ["[1][0]" reference] ["[1][0]" language ["[1]/[0]" lux]] - ["[1][0]" meta - ["[1]/[0]" io]]]) + ["[1][0]" meta]]) (def .public test Test @@ -33,5 +32,5 @@ /language/lux.test - /meta/io.test + /meta.test ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux index b5e4e04ed..145017a7e 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.use "[1]#[0]" equivalence) @@ -64,7 +64,7 @@ (_.for [/.equivalence] (equivalenceT.spec (/.equivalence n.equivalence) random)) (_.for [/.hash] - ($hash.spec (/.hash n.hash) random)) + (hashT.spec (/.hash n.hash) random)) (_.for [/.Tag] ..test|tag) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux index 2ffea9b19..2ade58534 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux @@ -5,8 +5,8 @@ ["[0]" monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [control ["[0]" pipe] ["[0]" try] @@ -203,7 +203,7 @@ (_.for [/.equivalence] (equivalenceT.spec (/.equivalence n.equivalence) ..random)) (_.for [/.hash] - ($hash.spec (/.hash n.hash) ..random)) + (hashT.spec (/.hash n.hash) ..random)) (<| (_.for [/.Operation]) (all _.and diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux index 22eef4b16..25d80755b 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.use "[1]#[0]" equivalence)]] @@ -35,7 +35,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.format] (bit#= (of /.equivalence = left right) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux index a0eac562a..183a05cc2 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.use "[1]#[0]" equivalence)]] @@ -35,7 +35,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.format] (bit#= (of /.equivalence = left right) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux index ca31f785f..c40da0a44 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.use "[1]#[0]" equivalence)]] @@ -39,7 +39,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.format] (bit#= (text#= (/.format left) (/.format right)) diff --git a/stdlib/source/test/lux/meta/compiler/meta.lux b/stdlib/source/test/lux/meta/compiler/meta.lux new file mode 100644 index 000000000..c2d1ac5c6 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/meta.lux @@ -0,0 +1,32 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [meta + ["[0]" version]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]] + ["[0]" / + ["[1][0]" io] + ["[1][0]" archive]]) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + []) + (all _.and + (_.coverage [/.version] + (not (n.= version.latest + /.version))) + + /io.test + /archive.test + ))) diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive.lux b/stdlib/source/test/lux/meta/compiler/meta/archive.lux index 1076b0373..07a8da0cc 100644 --- a/stdlib/source/test/lux/meta/compiler/meta/archive.lux +++ b/stdlib/source/test/lux/meta/compiler/meta/archive.lux @@ -198,7 +198,6 @@ (def .public test Test (<| (_.covering /._) - (_.for [/.Archive]) (do random.monad [module/0 (random.lower_cased 1) module/1 (random.lower_cased 2) @@ -208,44 +207,46 @@ hash random.nat .let [key (/key.key signature content/0)]]) (all _.and - (_.coverage [/.empty] - (list.empty? (/.entries /.empty))) - (_.coverage [/.reserve /.id] - (|> (do try.monad - [[@module/0 archive] (/.reserve module/0 /.empty) - [@module/1 archive] (/.reserve module/1 archive) - @module/0' (/.id module/0 archive) - @module/1' (/.id module/1 archive)] - (in (and (same? @module/0 @module/0') - (same? @module/1 @module/1')))) - (try.else false))) - (_.coverage [/.reserved] - (|> (do try.monad - [[@module/0 archive] (/.reserve module/0 /.empty) - [@module/1 archive] (/.reserve module/1 archive)] - (in (set#= (set.of_list text.hash (list module/0 module/1)) - (set.of_list text.hash (/.reserved archive))))) - (try.else false))) - (_.coverage [/.reservations] - (|> (do try.monad - [[@module/0 archive] (/.reserve module/0 /.empty) - [@module/1 archive] (/.reserve module/1 archive) - .let [hash (product.hash text.hash n.hash)]] - (in (set#= (set.of_list hash (list [module/0 @module/0] [module/1 @module/1])) - (set.of_list hash (/.reservations archive))))) - (try.else false))) - (_.coverage [/.module_has_already_been_reserved] - (|> (do try.monad - [[@module/0 archive] (/.reserve module/0 /.empty) - _ (/.reserve module/0 archive)] - (in false)) - (exception.otherwise (exception.match? /.module_has_already_been_reserved)))) - (_.coverage [/.reserved?] - (|> (do try.monad - [[@module/0 archive] (/.reserve module/0 /.empty)] - (in (and (/.reserved? archive module/0) - (not (/.reserved? archive module/1))))) - (try.else false))) + (<| (_.for [/.Archive]) + (all _.and + (_.coverage [/.empty] + (list.empty? (/.entries /.empty))) + (_.coverage [/.reserve /.id] + (|> (do try.monad + [[@module/0 archive] (/.reserve module/0 /.empty) + [@module/1 archive] (/.reserve module/1 archive) + @module/0' (/.id module/0 archive) + @module/1' (/.id module/1 archive)] + (in (and (same? @module/0 @module/0') + (same? @module/1 @module/1')))) + (try.else false))) + (_.coverage [/.reserved] + (|> (do try.monad + [[@module/0 archive] (/.reserve module/0 /.empty) + [@module/1 archive] (/.reserve module/1 archive)] + (in (set#= (set.of_list text.hash (list module/0 module/1)) + (set.of_list text.hash (/.reserved archive))))) + (try.else false))) + (_.coverage [/.reservations] + (|> (do try.monad + [[@module/0 archive] (/.reserve module/0 /.empty) + [@module/1 archive] (/.reserve module/1 archive) + .let [hash (product.hash text.hash n.hash)]] + (in (set#= (set.of_list hash (list [module/0 @module/0] [module/1 @module/1])) + (set.of_list hash (/.reservations archive))))) + (try.else false))) + (_.coverage [/.module_has_already_been_reserved] + (|> (do try.monad + [[@module/0 archive] (/.reserve module/0 /.empty) + _ (/.reserve module/0 archive)] + (in false)) + (exception.otherwise (exception.match? /.module_has_already_been_reserved)))) + (_.coverage [/.reserved?] + (|> (do try.monad + [[@module/0 archive] (/.reserve module/0 /.empty)] + (in (and (/.reserved? archive module/0) + (not (/.reserved? archive module/1))))) + (try.else false))))) (_.for [/.Entry] ..test|entry) diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux index c452662f9..44fa0fc5e 100644 --- a/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux +++ b/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux @@ -29,10 +29,6 @@ (random#in []) ..random_definition (random.lower_cased 2) - (random.lower_cased 3) - (random.lower_cased 4) - (random.lower_cased 5) - (random.lower_cased 6) )) (def .public test diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux index e13e1dca1..f0990eb71 100644 --- a/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux +++ b/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux @@ -79,45 +79,33 @@ _ false))) - (,, (with_template [ ' '] + (,, (with_template [ ' ] [(_.coverage [ ] (let [ ' - '] - (and (let [[@it registry] ( mandatory? expected_dependencies /.empty)] - (and (when ( registry) - (list actual_name) + [@it registry] ( mandatory? expected_dependencies /.empty)] + (and (when ( registry) + (list actual_name) + (same? actual_name) + + _ + false) + (when (sequence.list (/.artifacts registry)) + (list [artifact actual_dependencies]) + (and (same? @it (the artifact.#id artifact)) + (same? mandatory? (the artifact.#mandatory? artifact)) + (when (the artifact.#category artifact) + { actual_name} (same? actual_name) _ false) - (when (sequence.list (/.artifacts registry)) - (list [artifact actual_dependencies]) - (and (same? @it (the artifact.#id artifact)) - (same? mandatory? (the artifact.#mandatory? artifact)) - (when (the artifact.#category artifact) - { actual_name} - (same? actual_name) - - _ - false) - (same? expected_dependencies actual_dependencies)) - - _ - false))) - (let [[@it registry] ( mandatory? expected_dependencies /.empty)] - (when ( registry) - (list) - true + (same? expected_dependencies actual_dependencies)) - _ - false)))))] + _ + false))))] - [/.definition (is category.Definition [expected_name {.#None}]) /.definitions category.#Definition /.analyser expected_name] - [/.analyser expected_name /.analysers category.#Analyser /.synthesizer expected_name] - [/.synthesizer expected_name /.synthesizers category.#Synthesizer /.translator expected_name] - [/.translator expected_name /.translators category.#Translator /.declaration expected_name] - [/.declaration expected_name /.declarations category.#Declaration /.custom expected_name] - [/.custom expected_name /.customs category.#Custom /.definition (is category.Definition [expected_name {.#None}])] + [/.definition (is category.Definition [expected_name {.#None}]) /.definitions category.#Definition] + [/.custom expected_name /.customs category.#Custom] )) (_.coverage [/.id] (and (,, (with_template [ ' ] @@ -128,10 +116,6 @@ (maybe.else false)))] [/.definition (is category.Definition [expected_name {.#None}]) product.left] - [/.analyser expected_name |>] - [/.synthesizer expected_name |>] - [/.translator expected_name |>] - [/.declaration expected_name |>] [/.custom expected_name |>] )))) (_.coverage [/.artifacts] @@ -153,10 +137,6 @@ [/.definition /.definitions category.definition_equivalence (is (-> Text category.Definition) (function (_ it) [it {.#None}]))] - [/.analyser /.analysers text.equivalence (|>>)] - [/.synthesizer /.synthesizers text.equivalence (|>>)] - [/.translator /.translators text.equivalence (|>>)] - [/.declaration /.declarations text.equivalence (|>>)] [/.custom /.customs text.equivalence (|>>)] )))) (_.coverage [/.format /.parser] @@ -172,10 +152,6 @@ (try.else false)))] [/.definition (is category.Definition [expected_name {.#None}]) product.left] - [/.analyser expected_name |>] - [/.synthesizer expected_name |>] - [/.translator expected_name |>] - [/.declaration expected_name |>] [/.custom expected_name |>] )))) ))))) diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux index 3381e5872..beeda29dd 100644 --- a/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux +++ b/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux @@ -4,8 +4,8 @@ [abstract ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data [collection ["[0]" set]]] @@ -31,7 +31,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.none] (set.empty? /.none)) diff --git a/stdlib/source/test/lux/meta/compiler/reference.lux b/stdlib/source/test/lux/meta/compiler/reference.lux index 145230014..a0bd549bc 100644 --- a/stdlib/source/test/lux/meta/compiler/reference.lux +++ b/stdlib/source/test/lux/meta/compiler/reference.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format]]] @@ -52,7 +52,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (,, (with_template [] [(_.coverage [] diff --git a/stdlib/source/test/lux/meta/compiler/reference/variable.lux b/stdlib/source/test/lux/meta/compiler/reference/variable.lux index b25c0e755..f047de3b3 100644 --- a/stdlib/source/test/lux/meta/compiler/reference/variable.lux +++ b/stdlib/source/test/lux/meta/compiler/reference/variable.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" text (.use "[1]#[0]" equivalence)]] [math @@ -34,7 +34,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.self] (when (/.self) diff --git a/stdlib/source/test/lux/meta/macro/syntax/check.lux b/stdlib/source/test/lux/meta/macro/syntax/check.lux index 623b944b8..6bdf0f524 100644 --- a/stdlib/source/test/lux/meta/macro/syntax/check.lux +++ b/stdlib/source/test/lux/meta/macro/syntax/check.lux @@ -30,7 +30,8 @@ (def .public test Test (<| (_.covering /._) - (_.for [/.Check]) + (_.for [/.Check + /.#type /.#value]) (all _.and (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) diff --git a/stdlib/source/test/lux/meta/symbol.lux b/stdlib/source/test/lux/meta/symbol.lux index 430217ed4..56d7ff113 100644 --- a/stdlib/source/test/lux/meta/symbol.lux +++ b/stdlib/source/test/lux/meta/symbol.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" equivalence @@ -49,7 +49,7 @@ (_.for [/.hash] (|> (random.ascii 1) (of ! each (|>> [""])) - ($hash.spec /.hash))) + (hashT.spec /.hash))) (_.for [/.order] (orderT.spec /.order (..random sizeM1 sizeS1))) (_.for [/.codec] diff --git a/stdlib/source/test/lux/meta/target/jvm.lux b/stdlib/source/test/lux/meta/target/jvm.lux index 2487c7e3b..dffacdfaa 100644 --- a/stdlib/source/test/lux/meta/target/jvm.lux +++ b/stdlib/source/test/lux/meta/target/jvm.lux @@ -20,8 +20,8 @@ [collection ["[0]" array] ["[0]" dictionary] - ["[0]" sequence] ["[0]" set] + ["[0]" sequence] ["[0]" list (.use "[1]#[0]" functor)]]] [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)] @@ -139,7 +139,7 @@ {.#Some (do /.monad [_ bytecode] /.areturn)})) - (sequence.sequence)) + (list)) .let [bytecode (binary.result /class.format class) loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) @@ -909,7 +909,7 @@ _ /.ladd _ ..$Long::wrap] /.areturn)})) - (sequence.sequence)) + (list)) try.trusted (binary.result /class.format)) loader (/loader.memory (/loader.new_library []))]] @@ -976,67 +976,67 @@ (write_and_read size constructor value literal [*store *load *wrap] test))))))] (all _.and (_.context "boolean" - (array (/.newarray /instruction.t_boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap] - (function (_ expected) (|>> (as Bit) (bit#= (as Bit expected)))))) + (array (/.newarray /instruction.t_boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap] + (function (_ expected) (|>> (as Bit) (bit#= (as Bit expected)))))) (_.context "byte" - (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) - - @.jvm - (|>> (as java/lang/Byte) ffi.byte_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.byte_to_long (as java/lang/Byte expected))))))))) + (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) + + @.jvm + (|>> (as java/lang/Byte) ffi.byte_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.byte_to_long (as java/lang/Byte expected))))))))) (_.context "short" - (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) - - @.jvm - (|>> (as java/lang/Short) ffi.short_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.short_to_long (as java/lang/Short expected))))))))) + (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) + + @.jvm + (|>> (as java/lang/Short) ffi.short_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.short_to_long (as java/lang/Short expected))))))))) (_.context "int" - (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Integer) ("jvm ieq" (as java/lang/Integer expected))) - - @.jvm - (|>> (as java/lang/Integer) .jvm_object_cast# (.jvm_int_=# (.jvm_object_cast# (as java/lang/Integer expected)))))))) + (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Integer) ("jvm ieq" (as java/lang/Integer expected))) + + @.jvm + (|>> (as java/lang/Integer) .jvm_object_cast# (.jvm_int_=# (.jvm_object_cast# (as java/lang/Integer expected)))))))) (_.context "long" - (array (/.newarray /instruction.t_long) $Long::random $Long::literal [/.lastore /.laload $Long::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Long) ("jvm leq" expected)) - - @.jvm - (|>> (as java/lang/Long) .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (as java/lang/Long expected)))))))) + (array (/.newarray /instruction.t_long) $Long::random $Long::literal [/.lastore /.laload $Long::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Long) ("jvm leq" expected)) + + @.jvm + (|>> (as java/lang/Long) .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (as java/lang/Long expected)))))))) (_.context "float" - (array (/.newarray /instruction.t_float) ..valid_float $Float::literal [/.fastore /.faload $Float::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Float) ("jvm feq" expected)) - - @.jvm - (|>> (as java/lang/Float) .jvm_object_cast# (.jvm_float_=# (.jvm_object_cast# (as java/lang/Float expected)))))))) + (array (/.newarray /instruction.t_float) ..valid_float $Float::literal [/.fastore /.faload $Float::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Float) ("jvm feq" expected)) + + @.jvm + (|>> (as java/lang/Float) .jvm_object_cast# (.jvm_float_=# (.jvm_object_cast# (as java/lang/Float expected)))))))) (_.context "double" - (array (/.newarray /instruction.t_double) ..valid_double $Double::literal [/.dastore /.daload $Double::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Double) ("jvm deq" expected)) - - @.jvm - (|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# (as java/lang/Double expected)))))))) + (array (/.newarray /instruction.t_double) ..valid_double $Double::literal [/.dastore /.daload $Double::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Double) ("jvm deq" expected)) + + @.jvm + (|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# (as java/lang/Double expected)))))))) (_.context "char" - (array (/.newarray /instruction.t_char) $Character::random $Character::literal [/.castore /.caload $Character::wrap] - (function (_ expected) - (for @.old - (|>> (as java/lang/Character) ("jvm ceq" expected)) - - @.jvm - (|>> (as java/lang/Character) .jvm_object_cast# (.jvm_char_=# (.jvm_object_cast# (as java/lang/Character expected)))))))) + (array (/.newarray /instruction.t_char) $Character::random $Character::literal [/.castore /.caload $Character::wrap] + (function (_ expected) + (for @.old + (|>> (as java/lang/Character) ("jvm ceq" expected)) + + @.jvm + (|>> (as java/lang/Character) .jvm_object_cast# (.jvm_char_=# (.jvm_object_cast# (as java/lang/Character expected)))))))) (_.context "object" - (array (/.anewarray ..$String) $String::random $String::literal [/.aastore /.aaload /.nop] - (function (_ expected) (|>> (as Text) (text#= (as Text expected)))))) + (array (/.anewarray ..$String) $String::random $String::literal [/.aastore /.aaload /.nop] + (function (_ expected) (|>> (as Text) (text#= (as Text expected)))))) (<| (_.context "multi") (do [! random.monad] [.let [size (of ! each (|>> (n.% 5) (n.+ 1)) @@ -1378,7 +1378,7 @@ (substitute expected)) _ (the #wrap primitive)] /.areturn)})) - (sequence.sequence)) + (list)) .let [bytecode (binary.result /class.format class) loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) @@ -1659,7 +1659,7 @@ (list) (list (/method.method (all /modifier#composite /method.public /method.abstract) interface_method false method::type (list) {.#None})) - (sequence.sequence)) + (list)) try.trusted (binary.result /class.format)) abstract_bytecode (|> (/class.class /version.v6_0 (all /modifier#composite /class.public /class.abstract) @@ -1680,7 +1680,7 @@ (method overriden_method fake_part2) (/method.method (all /modifier#composite /method.public /method.abstract) abstract_method false method::type (list) {.#None})) - (sequence.sequence)) + (list)) try.trusted (binary.result /class.format)) invoke (is (-> (Type Class) Text (Bytecode Any)) @@ -1728,7 +1728,7 @@ _ /.ladd _ ..$Long::wrap] /.areturn)})) - (sequence.sequence)) + (list)) try.trusted (binary.result /class.format)) loader (/loader.memory (/loader.new_library []))]] diff --git a/stdlib/source/test/lux/meta/target/lua.lux b/stdlib/source/test/lux/meta/target/lua.lux index 68012d0a8..8aa357f30 100644 --- a/stdlib/source/test/lux/meta/target/lua.lux +++ b/stdlib/source/test/lux/meta/target/lua.lux @@ -4,8 +4,8 @@ ["[0]" ffi] [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]]] [control @@ -713,7 +713,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence random)) (_.for [/.hash] - ($hash.spec /.hash random)) + (hashT.spec /.hash random)) (_.coverage [/.manual] (expression (|>> (as Int) (i.= expected)) diff --git a/stdlib/source/test/lux/meta/target/python.lux b/stdlib/source/test/lux/meta/target/python.lux index 9d7e28a49..ac5ba6d0b 100644 --- a/stdlib/source/test/lux/meta/target/python.lux +++ b/stdlib/source/test/lux/meta/target/python.lux @@ -4,8 +4,8 @@ ["[0]" ffi] [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]]] [control @@ -831,7 +831,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random_expression)) (_.for [/.hash] - ($hash.spec /.hash ..random_expression)) + (hashT.spec /.hash ..random_expression)) (_.coverage [/.code /.manual] (|> (/.manual (/.code expected)) diff --git a/stdlib/source/test/lux/test/benchmark.lux b/stdlib/source/test/lux/test/benchmark.lux index e8ff950f3..10274d918 100644 --- a/stdlib/source/test/lux/test/benchmark.lux +++ b/stdlib/source/test/lux/test/benchmark.lux @@ -19,20 +19,23 @@ [\\library ["[0]" /]]) +(def (fibonacci it) + (-> Nat + Nat) + (when it + 0 0 + 1 1 + _ (n.+ (fibonacci (n.- 1 it)) + (fibonacci (n.- 2 it))))) + (def .public test Test (<| (_.covering /._) (do [! random.monad] - [angle random.safe_frac - - times (of ! each (n.% 10) random.nat) + [times (of ! each (n.% 10) random.nat) - .let [computation (is (IO Frac) - (io.io (|> angle - f.cos f.acos - f.sin f.asin - f.tan f.atan - f.exp f.log)))]]) + .let [computation (is (IO Nat) + (io.io (fibonacci 32)))]]) (all _.and (_.coverage [/.time] (io.run! @@ -45,8 +48,10 @@ (_.coverage [/.test] (io.run! (do io.monad - [it (/.test times computation)] - (in (and (n.= times (the /.#times it)) + [it (/.test times computation) + .let [performed_exact_number_of_times! + (n.= times (the /.#times it))]] + (in (and performed_exact_number_of_times! (when times 0 (and (duration.neutral? (the /.#minimum it)) (duration.neutral? (the /.#maximum it)) diff --git a/stdlib/source/test/lux/world/finance/market/price.lux b/stdlib/source/test/lux/world/finance/market/price.lux index 28c0db1f5..6525ce793 100644 --- a/stdlib/source/test/lux/world/finance/market/price.lux +++ b/stdlib/source/test/lux/world/finance/market/price.lux @@ -14,90 +14,82 @@ ["[0]" text (.only) ["%" \\format]]] [math - ["[0]" random (.only Random) (.use "[1]#[0]" functor)] + ["[0]" random (.only Random)] [number + ["n" nat] ["i" int]]] [test ["_" property (.only Test)]]]] [\\library ["[0]" / (.only) [/// - [money - ["[0]" currency (.only Currency)]]]]]) + ["[0]" money (.only) + ["[0]" currency (.only Currency)]]]]] + [/// + ["[0]T" money]]) -(def .public (random $) +(def .public (random $ max_sub_units) (All (_ $) - (-> (Currency $) + (-> (Currency $) Nat (Random (/.Action $)))) - (random#each (/.action $) - random.int)) + (do random.monad + [from (moneyT.random $ max_sub_units) + to (moneyT.random $ max_sub_units)] + (in (/.action from to)))) (def .public test Test (<| (_.covering /._) (do [! random.monad] - [expected_movement random.int + [parameter (..random currency.usd 1000,00) + subject (..random currency.usd 1000,00) - expected_parameter random.int - expected_subject random.int]) + from (moneyT.random currency.usd 1000,00) + to (moneyT.random currency.usd 1000,00)]) (_.for [/.Price /.Action]) (all _.and (_.for [/.equivalence /.=] - (equivalenceT.spec /.equivalence (..random currency.usd))) + (equivalenceT.spec /.equivalence (..random currency.usd 1000,00))) (_.for [/.order /.<] - (orderT.spec /.order (..random currency.usd))) + (orderT.spec /.order (..random currency.usd 1000,00))) (_.coverage [/.action /.currency /.movement] - (let [it (/.action currency.usd expected_movement)] + (let [it (/.action from to)] (and (same? currency.usd (/.currency it)) - (same? expected_movement (/.movement it))))) + (i.= (int (n.- (money.amount from) (money.amount to))) + (/.movement it))))) (_.coverage [/.+ /.-] - (let [parameter (/.action currency.usd expected_parameter) - subject (/.action currency.usd expected_subject)] - (and (|> subject - (/.+ parameter) - (of /.equivalence = subject) - not) - (|> subject - (/.+ parameter) - (/.- parameter) - (of /.equivalence = subject))))) + (and (|> subject + (/.+ parameter) + (of /.equivalence = subject) + not) + (|> subject + (/.+ parameter) + (/.- parameter) + (of /.equivalence = subject)))) (_.coverage [/.min] - (let [expected_parameter (/.action currency.usd expected_parameter) - expected_subject (/.action currency.usd expected_subject)] - (and (/.<= expected_parameter - (/.min expected_parameter expected_subject)) - (/.<= expected_subject - (/.min expected_parameter expected_subject))))) + (and (/.<= parameter + (/.min parameter subject)) + (/.<= subject + (/.min parameter subject)))) (_.coverage [/.max] - (let [expected_parameter (/.action currency.usd expected_parameter) - expected_subject (/.action currency.usd expected_subject)] - (and (/.>= expected_parameter - (/.max expected_parameter expected_subject)) - (/.>= expected_subject - (/.max expected_parameter expected_subject))))) - (let [expected_parameter (/.action currency.usd expected_parameter) - expected_subject (/.action currency.usd expected_subject)] - (all _.and - (_.coverage [/.>] - (bit#= (/.> expected_parameter expected_subject) - (/.< expected_subject expected_parameter))) - (_.coverage [/.<= /.>=] - (bit#= (/.<= expected_parameter expected_subject) - (/.>= expected_subject expected_parameter))) - )) - (_.coverage [/.units /.sub_units] - (let [expected (/.action currency.usd expected_movement) - actual (/.action currency.usd (i.+ (/.units expected) - (/.sub_units expected)))] - (/.= expected actual))) - (_.coverage [/.of_units /.of_sub_units] - (let [expected (/.action currency.usd expected_movement) - actual (/.+ (/.of_units currency.usd (/.units expected)) - (/.of_sub_units currency.usd (/.sub_units expected)))] - (/.= expected actual))) + (and (/.>= parameter + (/.max parameter subject)) + (/.>= subject + (/.max parameter subject)))) + (_.coverage [/.>] + (bit#= (/.> parameter subject) + (/.< subject parameter))) + (_.coverage [/.<= /.>=] + (bit#= (/.<= parameter subject) + (/.>= subject parameter))) + (_.coverage [/.units /.sub_units + /.of_units /.of_sub_units] + (/.= subject + (/.+ (/.of_units currency.usd (/.units subject)) + (/.of_sub_units currency.usd (/.sub_units subject))))) (do ! - [it (..random currency.usd)] + [it (..random currency.usd 1000,00)] (_.coverage [/.format] (and (text.starts_with? (%.int (/.movement it)) (text.replaced_once "." "" (/.format it))) diff --git a/stdlib/source/test/lux/world/locale.lux b/stdlib/source/test/lux/world/locale.lux index 92510dd26..73dd6ddd2 100644 --- a/stdlib/source/test/lux/world/locale.lux +++ b/stdlib/source/test/lux/world/locale.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]]] [math @@ -63,15 +63,15 @@ (|> ..random_language (of ! each (function (_ language) (/.locale language {.#Some fixed_territory} {.#Some fixed_encoding}))) - ($hash.spec /.hash)) + (hashT.spec /.hash)) (|> ..random_territory (of ! each (function (_ territory) (/.locale fixed_language {.#Some territory} {.#Some fixed_encoding}))) - ($hash.spec /.hash)) + (hashT.spec /.hash)) (|> ..random_encoding (of ! each (function (_ encoding) (/.locale fixed_language {.#Some fixed_territory} {.#Some encoding}))) - ($hash.spec /.hash)) + (hashT.spec /.hash)) ))) (do random.monad diff --git a/stdlib/source/test/lux/world/locale/language.lux b/stdlib/source/test/lux/world/locale/language.lux index 12020bfe7..66546e29f 100644 --- a/stdlib/source/test/lux/world/locale/language.lux +++ b/stdlib/source/test/lux/world/locale/language.lux @@ -4,8 +4,8 @@ [abstract [monad (.only do)] [hash (.only Hash)] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [control ["[0]" maybe]] [data @@ -295,7 +295,7 @@ (_.for [/.Language]) (all _.and (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) ..languages_test ..aliases_test diff --git a/stdlib/source/test/lux/world/locale/territory.lux b/stdlib/source/test/lux/world/locale/territory.lux index f39ff6627..c3799f7b6 100644 --- a/stdlib/source/test/lux/world/locale/territory.lux +++ b/stdlib/source/test/lux/world/locale/territory.lux @@ -4,8 +4,8 @@ [abstract [monad (.only do)] [hash (.only Hash)] - [\\specification - ["$[0]" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [control ["[0]" maybe]] [data @@ -221,7 +221,7 @@ (_.for [/.Territory]) (all _.and (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) ..territories_test ..aliases_test diff --git a/stdlib/source/test/lux/world/net/http/version.lux b/stdlib/source/test/lux/world/net/http/version.lux index 5891f3768..2f4b38625 100644 --- a/stdlib/source/test/lux/world/net/http/version.lux +++ b/stdlib/source/test/lux/world/net/http/version.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]]] [data @@ -39,7 +39,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.v0_9 /.v1_0 /.v1_1 /.v2_0] (let [options (list /.v0_9 /.v1_0 /.v1_1 /.v2_0) diff --git a/stdlib/source/test/lux/world/net/mime.lux b/stdlib/source/test/lux/world/net/mime.lux index 18f6521c1..65ea9535a 100644 --- a/stdlib/source/test/lux/world/net/mime.lux +++ b/stdlib/source/test/lux/world/net/mime.lux @@ -5,8 +5,8 @@ [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] - [\\specification - ["[0]S" hash]]] + ["[0]" hash + ["[1]T" \\test]]] [data ["[0]" text (.only) ["[0]" encoding (.only) @@ -160,7 +160,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - (hashS.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.mime /.name] (|> expected diff --git a/stdlib/source/test/lux/world/net/uri/scheme.lux b/stdlib/source/test/lux/world/net/uri/scheme.lux index 200b0fce5..ba02871ec 100644 --- a/stdlib/source/test/lux/world/net/uri/scheme.lux +++ b/stdlib/source/test/lux/world/net/uri/scheme.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]]] [data @@ -61,7 +61,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [/.name /.scheme] (|> expected diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux index c05173d2a..0dec2c08a 100644 --- a/stdlib/source/test/lux/world/output/video/resolution.lux +++ b/stdlib/source/test/lux/world/output/video/resolution.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" equivalence ["[1]T" \\test]]] [control @@ -60,7 +60,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.coverage [] (n.= (list.size ..listing) diff --git a/stdlib/source/test/lux/world/time/day.lux b/stdlib/source/test/lux/world/time/day.lux index be1812d92..4af557a8a 100644 --- a/stdlib/source/test/lux/world/time/day.lux +++ b/stdlib/source/test/lux/world/time/day.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" enum ["[1]T" \\test]] ["[0]" codec @@ -54,7 +54,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.for [/.order] (orderT.spec /.order ..random)) (_.for [/.enum] diff --git a/stdlib/source/test/lux/world/time/instant.lux b/stdlib/source/test/lux/world/time/instant.lux index 889cfa612..104aa82a1 100644 --- a/stdlib/source/test/lux/world/time/instant.lux +++ b/stdlib/source/test/lux/world/time/instant.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" enum ["[1]T" \\test]] ["[0]" codec @@ -40,7 +40,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence random.instant)) (_.for [/.hash] - ($hash.spec /.hash random.instant)) + (hashT.spec /.hash random.instant)) (_.for [/.order] (orderT.spec /.order random.instant)) (_.for [/.enum] diff --git a/stdlib/source/test/lux/world/time/month.lux b/stdlib/source/test/lux/world/time/month.lux index 29cb2d725..9f30db09b 100644 --- a/stdlib/source/test/lux/world/time/month.lux +++ b/stdlib/source/test/lux/world/time/month.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["$[0]" hash]] + ["[0]" hash + ["[1]T" \\test]] ["[0]" enum ["[1]T" \\test]] ["[0]" codec @@ -48,7 +48,7 @@ (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..random)) (_.for [/.hash] - ($hash.spec /.hash ..random)) + (hashT.spec /.hash ..random)) (_.for [/.order] (orderT.spec /.order ..random)) (_.for [/.enum] -- cgit v1.2.3