From 240a4465157bb903dd2a3ee4cdc28aadf09f8dcb Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 19 Dec 2022 20:56:06 -0400 Subject: Added price-action abstraction. --- stdlib/source/specification/lux/abstract/codec.lux | 28 --------- stdlib/source/specification/lux/abstract/enum.lux | 10 ++-- .../lux/abstract/functor/contravariant.lux | 32 ---------- .../source/specification/lux/abstract/monoid.lux | 33 ---------- stdlib/source/specification/lux/abstract/order.lux | 70 ---------------------- .../source/specification/lux/math/arithmetic.lux | 5 -- 6 files changed, 5 insertions(+), 173 deletions(-) delete mode 100644 stdlib/source/specification/lux/abstract/codec.lux delete mode 100644 stdlib/source/specification/lux/abstract/functor/contravariant.lux delete mode 100644 stdlib/source/specification/lux/abstract/monoid.lux delete mode 100644 stdlib/source/specification/lux/abstract/order.lux (limited to 'stdlib/source/specification') diff --git a/stdlib/source/specification/lux/abstract/codec.lux b/stdlib/source/specification/lux/abstract/codec.lux deleted file mode 100644 index e4e9d3bed..000000000 --- a/stdlib/source/specification/lux/abstract/codec.lux +++ /dev/null @@ -1,28 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [monad (.only do)]] - [control - ["[0]" try]] - [math - ["[0]" random (.only Random)]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" / (.only) - [// - [equivalence (.only Equivalence)]]]]) - -(def .public (spec (open "/#[0]") (open "/#[0]") generator) - (All (_ m a) (-> (Equivalence a) (/.Codec m a) (Random a) Test)) - (do random.monad - [expected generator] - (_.for [/.Codec] - (_.coverage [/.encoded /.decoded] - (when (|> expected /#encoded /#decoded) - {try.#Success actual} - (/#= expected actual) - - {try.#Failure _} - false))))) diff --git a/stdlib/source/specification/lux/abstract/enum.lux b/stdlib/source/specification/lux/abstract/enum.lux index 569e67181..0d367f7c0 100644 --- a/stdlib/source/specification/lux/abstract/enum.lux +++ b/stdlib/source/specification/lux/abstract/enum.lux @@ -2,15 +2,15 @@ [library [lux (.except) [abstract - [monad (.only do)]] + [monad (.only do)] + ["[0]" order + ["[1]T" \\test]]] [math ["[0]" random (.only Random)]] [test ["_" property (.only Test)]]]] [\\library - ["[0]" /]] - [// - ["[0]S" order]]) + ["[0]" /]]) (def .public (spec (open "/#[0]") random) (All (_ a) (-> (/.Enum a) (Random a) Test)) @@ -19,7 +19,7 @@ (<| (_.for [/.Enum]) (all _.and (_.for [/.order] - (orderS.spec /#order random)) + (orderT.spec /#order random)) (_.coverage [/.succ /.pred] (and (/#= (|> sample /#succ /#pred) sample) diff --git a/stdlib/source/specification/lux/abstract/functor/contravariant.lux b/stdlib/source/specification/lux/abstract/functor/contravariant.lux deleted file mode 100644 index aa7d63d43..000000000 --- a/stdlib/source/specification/lux/abstract/functor/contravariant.lux +++ /dev/null @@ -1,32 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [equivalence (.only Equivalence)] - [monad (.only do)]] - [control - ["[0]" function]] - [math - ["[0]" random] - [number - ["n" nat]]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" / (.only Functor)]]) - -(def (identity equivalence value (open "@//[0]")) - (All (_ f a) (-> (Equivalence (f a)) (f a) (Functor f) Test)) - (_.test "Law of identity." - (equivalence - (@//each function.identity value) - value))) - -(def .public (spec equivalence value functor) - (All (_ f a) (-> (Equivalence (f a)) (f a) (Functor f) Test)) - (do random.monad - [sample random.nat] - (<| (_.for [/.Functor]) - (all _.and - (..identity equivalence value functor) - )))) diff --git a/stdlib/source/specification/lux/abstract/monoid.lux b/stdlib/source/specification/lux/abstract/monoid.lux deleted file mode 100644 index fe69e9f6b..000000000 --- a/stdlib/source/specification/lux/abstract/monoid.lux +++ /dev/null @@ -1,33 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [monad (.only do)]] - [math - ["[0]" random (.only Random)]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" / (.only) - [// - [equivalence (.only Equivalence)]]]]) - -(def .public (spec (open "_#[0]") (open "_#[0]") gen_sample) - (All (_ a) (-> (Equivalence a) (/.Monoid a) (Random a) Test)) - (do random.monad - [sample gen_sample - left gen_sample - mid gen_sample - right gen_sample] - (<| (_.for [/.Monoid]) - (all _.and - (_.test "Left identity." - (_#= sample - (_#composite _#identity sample))) - (_.test "Right identity." - (_#= sample - (_#composite sample _#identity))) - (_.test "Associativity." - (_#= (_#composite left (_#composite mid right)) - (_#composite (_#composite left mid) right))) - )))) diff --git a/stdlib/source/specification/lux/abstract/order.lux b/stdlib/source/specification/lux/abstract/order.lux deleted file mode 100644 index 1bf62b3cc..000000000 --- a/stdlib/source/specification/lux/abstract/order.lux +++ /dev/null @@ -1,70 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [monad (.only do)]] - [data - ["[0]" bit (.use "[1]#[0]" equivalence)]] - [math - ["[0]" random (.only Random)]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" /]] - [// - ["[0]S" equivalence]]) - -(def .public (spec (open "/#[0]") random) - (All (_ of) - (-> (/.Order of) (Random of) - Test)) - (<| (_.for [/.Order]) - (all _.and - (_.for [/.equivalence] - (equivalenceS.spec /#equivalence random)) - - (do random.monad - [parameter random - subject random - .let [equal_or_ordered! - (let [equal! - (/#= parameter subject) - - ordered! - (or (and (/#< parameter subject) - (not (/#< subject parameter))) - (and (/#< subject parameter) - (not (/#< parameter subject))))] - (bit#= equal! (not ordered!)))] - - subject (random.only (|>> (/#= parameter) not) - random) - extra (random.only (function (_ value) - (not (or (/#= parameter value) - (/#= subject value)))) - random) - .let [transitive_property! - (if (/#< parameter subject) - (let [greater? (and (/#< subject extra) - (/#< parameter extra)) - lesser? (and (/#< extra parameter) - (/#< extra subject)) - in_between? (and (/#< parameter extra) - (/#< extra subject))] - (or greater? - lesser? - in_between?)) - ... (/#< subject parameter) - (let [greater? (and (/#< extra subject) - (/#< extra parameter)) - lesser? (and (/#< parameter extra) - (/#< subject extra)) - in_between? (and (/#< subject extra) - (/#< extra parameter))] - (or greater? - lesser? - in_between?)))]] - (_.coverage [/.<] - (and equal_or_ordered! - transitive_property!))) - ))) diff --git a/stdlib/source/specification/lux/math/arithmetic.lux b/stdlib/source/specification/lux/math/arithmetic.lux index 7ae9f3f06..9b8d1fb7d 100644 --- a/stdlib/source/specification/lux/math/arithmetic.lux +++ b/stdlib/source/specification/lux/math/arithmetic.lux @@ -38,9 +38,4 @@ (|> left (/ one) (= left)) (|> left (/ left) (= one)) (|> left (* zero) (= zero)))) - (_.coverage [/.%] - (let [rem (% left right) - div (|> right (- rem) (/ left))] - (= right - (|> div (* left) (+ rem))))) )))) -- cgit v1.2.3