diff options
author | Eduardo Julian | 2022-12-22 17:21:26 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-12-22 17:21:26 -0400 |
commit | 6f1bf11af05bd03183fee7721ac99eca826ca041 (patch) | |
tree | 9661fdef01ebb7e4c1ead05e839d608bfab86217 /stdlib/source/test/lux/world | |
parent | 4f4a96635abb04239102e4b72dc2a9c6f678dcd2 (diff) |
Added some explicit machinery for the Any type.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/world.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/finance/market/analysis.lux | 50 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/finance/market/analysis/pivot_point.lux | 26 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/finance/trade/session.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/date.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/day.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/duration.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/instant.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/month.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/series.lux | 7 |
11 files changed, 99 insertions, 37 deletions
diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux index 2832e94be..cc48efe04 100644 --- a/stdlib/source/test/lux/world.lux +++ b/stdlib/source/test/lux/world.lux @@ -19,9 +19,7 @@ ["[1]/[0]" session]] ["[1]/[0]" market ["[1]/[0]" price] - ["[1]/[0]" analysis - ["[1]/[0]" accumulation_distribution] - ["[1]/[0]" pivot_point]]]] + ["[1]/[0]" analysis]]] ["[1][0]" net] ["[1][0]" time] ["[1][0]" locale] @@ -41,8 +39,7 @@ /finance/money.test /finance/trade/session.test /finance/market/price.test - /finance/market/analysis/accumulation_distribution.test - /finance/market/analysis/pivot_point.test + /finance/market/analysis.test /net.test /time.test diff --git a/stdlib/source/test/lux/world/finance/market/analysis.lux b/stdlib/source/test/lux/world/finance/market/analysis.lux new file mode 100644 index 000000000..9332a6dd6 --- /dev/null +++ b/stdlib/source/test/lux/world/finance/market/analysis.lux @@ -0,0 +1,50 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [world + [time + ["[0]" instant (.use "[1]#[0]" equivalence)] + ["[0]" duration (.use "[1]#[0]" equivalence)] + ["[0]" series (.only) + ["[1]T" \\test]]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]] + ["[0]" / + ["[1][0]" accumulation_distribution] + ["[1][0]" pivot_point]]) + +(def .public (spec random it) + (All (_ from to) + (-> (Random from) (/.Analysis from to) + Test)) + (do random.monad + [.let [expected_events 10] + input (seriesT.random expected_events random) + .let [output (it input)]] + (all _.and + (_.coverage [/.Analysis] + (and (instant#= (the series.#start input) + (the series.#start output)) + (duration#= (the series.#interval input) + (the series.#interval output)) + (n.= (series.size input) + (series.size output)))) + ))) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + []) + (all _.and + /accumulation_distribution.test + (/pivot_point.test spec) + ))) diff --git a/stdlib/source/test/lux/world/finance/market/analysis/pivot_point.lux b/stdlib/source/test/lux/world/finance/market/analysis/pivot_point.lux index bb7cd12b3..79eb95766 100644 --- a/stdlib/source/test/lux/world/finance/market/analysis/pivot_point.lux +++ b/stdlib/source/test/lux/world/finance/market/analysis/pivot_point.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except) + [lux (.except Analysis) [abstract [monad (.only do)]] [math @@ -9,19 +9,27 @@ ["_" property (.only Test)]]]] [\\library ["[0]" / (.only) - [//// - ["[0]" money (.only) - ["[0]" currency]] - [trade - ["[0]" session (.only) - ["[1]T" \\test]]]]]]) + [// (.only Analysis) + [/// + ["[0]" money (.only) + ["[0]" currency]] + [trade + ["[0]" session (.only) + ["[1]T" \\test]]]]]]]) -(def .public test - Test +(def .public (test spec) + (-> (All (_ from to) + (-> (Random from) (Analysis from to) + Test)) + Test) (<| (_.covering /._) (do [! random.monad] [session (sessionT.random currency.usd 1000,00)]) (all _.and + (_.for [/.analysis] + (spec (sessionT.random currency.usd 1000,00) + /.analysis)) + (_.coverage [/.typical_price] (let [it (/.typical_price session)] (and (money.<= (the session.#high session) diff --git a/stdlib/source/test/lux/world/finance/trade/session.lux b/stdlib/source/test/lux/world/finance/trade/session.lux index 70dde1b44..6c8be3332 100644 --- a/stdlib/source/test/lux/world/finance/trade/session.lux +++ b/stdlib/source/test/lux/world/finance/trade/session.lux @@ -28,13 +28,13 @@ (All (_ $) (-> (Currency $) Nat (Random (/.Session $)))) - (do random.monad + (do [! random.monad] [p0 (moneyT.random $ max_sub_units) p1 (moneyT.random $ max_sub_units) p2 (moneyT.random $ max_sub_units) p3 (moneyT.random $ max_sub_units) bullish? random.bit - volume random.nat] + volume (of ! each (n.% max_sub_units) random.nat)] (when (list.sorted money.< (list p0 p1 p2 p3)) (list low bottom top high) (in [/.#open (if bullish? diff --git a/stdlib/source/test/lux/world/time.lux b/stdlib/source/test/lux/world/time.lux index 4997cb844..bc049bc44 100644 --- a/stdlib/source/test/lux/world/time.lux +++ b/stdlib/source/test/lux/world/time.lux @@ -4,8 +4,9 @@ [abstract [monad (.only do)] [\\specification - ["$[0]" equivalence] - ["$[0]" enum]] + ["$[0]" equivalence]] + ["[0]" enum + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" order @@ -45,7 +46,7 @@ (_.for [/.order] (orderT.spec /.order random.time)) (_.for [/.enum] - ($enum.spec /.enum random.time)) + (enumT.spec /.enum random.time)) (_.for [/.codec] (codecT.spec /.equivalence /.codec random.time)))) diff --git a/stdlib/source/test/lux/world/time/date.lux b/stdlib/source/test/lux/world/time/date.lux index aff778c3c..306b3e252 100644 --- a/stdlib/source/test/lux/world/time/date.lux +++ b/stdlib/source/test/lux/world/time/date.lux @@ -4,8 +4,9 @@ [abstract [monad (.only do)] [\\specification - ["$[0]" equivalence] - ["$[0]" enum]] + ["$[0]" equivalence]] + ["[0]" enum + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" order @@ -37,7 +38,7 @@ (_.for [/.order] (orderT.spec /.order random.date)) (_.for [/.enum] - ($enum.spec /.enum random.date)) + (enumT.spec /.enum random.date)) (_.for [/.codec] (codecT.spec /.equivalence /.codec random.date)) diff --git a/stdlib/source/test/lux/world/time/day.lux b/stdlib/source/test/lux/world/time/day.lux index 46b3c7785..d0ac6f1d6 100644 --- a/stdlib/source/test/lux/world/time/day.lux +++ b/stdlib/source/test/lux/world/time/day.lux @@ -5,8 +5,9 @@ [monad (.only do)] [\\specification ["$[0]" equivalence] - ["$[0]" hash] - ["$[0]" enum]] + ["$[0]" hash]] + ["[0]" enum + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" order @@ -56,7 +57,7 @@ (_.for [/.order] (orderT.spec /.order ..random)) (_.for [/.enum] - ($enum.spec /.enum ..random)) + (enumT.spec /.enum ..random)) (_.for [/.codec] (codecT.spec /.equivalence /.codec ..random)) diff --git a/stdlib/source/test/lux/world/time/duration.lux b/stdlib/source/test/lux/world/time/duration.lux index f0e17332f..7900331b8 100644 --- a/stdlib/source/test/lux/world/time/duration.lux +++ b/stdlib/source/test/lux/world/time/duration.lux @@ -4,8 +4,9 @@ [abstract [monad (.only do)] [\\specification - ["$[0]" equivalence] - ["$[0]" enum]] + ["$[0]" equivalence]] + ["[0]" enum + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" order @@ -34,7 +35,7 @@ (_.for [/.order] (orderT.spec /.order random.duration)) (_.for [/.enum] - ($enum.spec /.enum random.duration)) + (enumT.spec /.enum random.duration)) (_.for [/.monoid] (monoidT.spec /.equivalence /.monoid random.duration)) (_.for [/.codec] diff --git a/stdlib/source/test/lux/world/time/instant.lux b/stdlib/source/test/lux/world/time/instant.lux index eebdd4fa0..03abc29c7 100644 --- a/stdlib/source/test/lux/world/time/instant.lux +++ b/stdlib/source/test/lux/world/time/instant.lux @@ -5,8 +5,9 @@ [monad (.only do)] [\\specification ["$[0]" equivalence] - ["$[0]" hash] - ["$[0]" enum]] + ["$[0]" hash]] + ["[0]" enum + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" order @@ -42,7 +43,7 @@ (_.for [/.order] (orderT.spec /.order random.instant)) (_.for [/.enum] - ($enum.spec /.enum random.instant)) + (enumT.spec /.enum random.instant)) (_.for [/.codec] (codecT.spec /.equivalence /.codec random.instant)) diff --git a/stdlib/source/test/lux/world/time/month.lux b/stdlib/source/test/lux/world/time/month.lux index 20d2d070e..9d1f05ab6 100644 --- a/stdlib/source/test/lux/world/time/month.lux +++ b/stdlib/source/test/lux/world/time/month.lux @@ -5,8 +5,9 @@ [monad (.only do)] [\\specification ["$[0]" equivalence] - ["$[0]" hash] - ["$[0]" enum]] + ["$[0]" hash]] + ["[0]" enum + ["[1]T" \\test]] ["[0]" codec ["[1]T" \\test]] ["[0]" order @@ -50,7 +51,7 @@ (_.for [/.order] (orderT.spec /.order ..random)) (_.for [/.enum] - ($enum.spec /.enum ..random)) + (enumT.spec /.enum ..random)) (_.for [/.codec] (codecT.spec /.equivalence /.codec ..random)) diff --git a/stdlib/source/test/lux/world/time/series.lux b/stdlib/source/test/lux/world/time/series.lux index ef42a994e..a43c1b682 100644 --- a/stdlib/source/test/lux/world/time/series.lux +++ b/stdlib/source/test/lux/world/time/series.lux @@ -5,9 +5,10 @@ [monad (.only do)] ["[0]" functor ["[1]T" \\test (.only Injection)]] + ["[0]" mix + ["[1]T" \\test]] [\\specification - ["[0]S" equivalence] - ["[0]S" mix]]] + ["[0]S" equivalence]]] [control ["|" pipe] ["[0]" try (.use "[1]#[0]" functor)] @@ -78,7 +79,7 @@ (_.for [/.equivalence] (equivalenceS.spec (/.equivalence n.equivalence) (..random expected_size random.nat))) (_.for [/.mix] - (mixS.spec (..injection expected_start expected_interval) /.equivalence /.mix)) + (mixT.spec (..injection expected_start expected_interval) /.equivalence /.mix)) (_.for [/.functor] (functorT.spec (..injection expected_start expected_interval) /.equivalence /.functor)) |