aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world
diff options
context:
space:
mode:
authorEduardo Julian2022-12-19 20:56:06 -0400
committerEduardo Julian2022-12-19 20:56:06 -0400
commit240a4465157bb903dd2a3ee4cdc28aadf09f8dcb (patch)
tree018925b984a788afdd343262010041492978394c /stdlib/source/test/lux/world
parentc2830c26e55da02ac628be9a220cd824264cdc9e (diff)
Added price-action abstraction.
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/world.lux2
-rw-r--r--stdlib/source/test/lux/world/finance/market/price.lux106
-rw-r--r--stdlib/source/test/lux/world/finance/money.lux7
-rw-r--r--stdlib/source/test/lux/world/finance/trade/session.lux2
-rw-r--r--stdlib/source/test/lux/world/net/uri/query.lux7
-rw-r--r--stdlib/source/test/lux/world/time.lux12
-rw-r--r--stdlib/source/test/lux/world/time/date.lux12
-rw-r--r--stdlib/source/test/lux/world/time/day.lux12
-rw-r--r--stdlib/source/test/lux/world/time/duration.lux17
-rw-r--r--stdlib/source/test/lux/world/time/instant.lux12
-rw-r--r--stdlib/source/test/lux/world/time/month.lux12
-rw-r--r--stdlib/source/test/lux/world/time/solar.lux4
-rw-r--r--stdlib/source/test/lux/world/time/year.lux12
13 files changed, 170 insertions, 47 deletions
diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux
index 3793d49ee..e4f9f5cec 100644
--- a/stdlib/source/test/lux/world.lux
+++ b/stdlib/source/test/lux/world.lux
@@ -18,6 +18,7 @@
["[1]/[0]" trade
["[1]/[0]" session]]
["[1]/[0]" market
+ ["[1]/[0]" price]
["[1]/[0]" analysis
["[1]/[0]" accumulation_distribution]]]]
["[1][0]" net]
@@ -38,6 +39,7 @@
/finance/money.test
/finance/trade/session.test
+ /finance/market/price.test
/finance/market/analysis/accumulation_distribution.test
/net.test
diff --git a/stdlib/source/test/lux/world/finance/market/price.lux b/stdlib/source/test/lux/world/finance/market/price.lux
new file mode 100644
index 000000000..d5b8232b5
--- /dev/null
+++ b/stdlib/source/test/lux/world/finance/market/price.lux
@@ -0,0 +1,106 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]
+ [\\specification
+ ["[0]S" equivalence]]
+ ["[0]" order
+ ["[1]T" \\test]]]
+ [control
+ ["[0]" maybe (.use "[1]#[0]" functor)]]
+ [data
+ ["[0]" bit (.use "[1]#[0]" equivalence)]
+ ["[0]" text (.only)
+ ["%" \\format]]]
+ [math
+ ["[0]" random (.only Random) (.use "[1]#[0]" functor)]
+ [number
+ ["i" int]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" / (.only)
+ [///
+ [money
+ ["[0]" currency (.only Currency)]]]]])
+
+(def .public (random $)
+ (All (_ $)
+ (-> (Currency $)
+ (Random (/.Action $))))
+ (random#each (/.action $)
+ random.int))
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [expected_movement random.int
+
+ expected_parameter random.int
+ expected_subject random.int])
+ (_.for [/.Price /.Action])
+ (all _.and
+ (_.for [/.equivalence /.=]
+ (equivalenceS.spec /.equivalence (..random currency.usd)))
+ (_.for [/.order /.<]
+ (orderT.spec /.order (..random currency.usd)))
+
+ (_.coverage [/.action /.currency /.movement]
+ (let [it (/.action currency.usd expected_movement)]
+ (and (same? currency.usd (/.currency it))
+ (same? expected_movement (/.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)))))
+ (_.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)))))
+ (_.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)))
+ (do !
+ [it (..random currency.usd)]
+ (_.coverage [/.format]
+ (and (text.starts_with? (%.int (/.movement it))
+ (text.replaced_once "." "" (/.format it)))
+ (text.ends_with? (currency.alphabetic_code (/.currency it))
+ (/.format it)))))
+ )))
diff --git a/stdlib/source/test/lux/world/finance/money.lux b/stdlib/source/test/lux/world/finance/money.lux
index 773589a15..073f19f34 100644
--- a/stdlib/source/test/lux/world/finance/money.lux
+++ b/stdlib/source/test/lux/world/finance/money.lux
@@ -4,8 +4,9 @@
[abstract
[monad (.only do)]
[\\specification
- ["[0]S" equivalence]
- ["[0]S" order]]]
+ ["[0]S" equivalence]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" maybe (.use "[1]#[0]" functor)]]
[data
@@ -44,7 +45,7 @@
(_.for [/.equivalence /.=]
(equivalenceS.spec /.equivalence (..random currency.usd)))
(_.for [/.order /.<]
- (orderS.spec /.order (..random currency.usd)))
+ (orderT.spec /.order (..random currency.usd)))
(_.coverage [/.money /.currency /.amount]
(let [it (/.money currency.usd expected_amount)]
diff --git a/stdlib/source/test/lux/world/finance/trade/session.lux b/stdlib/source/test/lux/world/finance/trade/session.lux
index 6ce1979d2..7519d63e3 100644
--- a/stdlib/source/test/lux/world/finance/trade/session.lux
+++ b/stdlib/source/test/lux/world/finance/trade/session.lux
@@ -56,7 +56,7 @@
(do [! random.monad]
[before (..random currency.usd)
after (..random currency.usd)])
- (_.for [/.Session /.Price /.Volume
+ (_.for [/.Session /.Volume
/.#open /.#high /.#low /.#close /.#volume])
(all _.and
(_.for [/.equivalence]
diff --git a/stdlib/source/test/lux/world/net/uri/query.lux b/stdlib/source/test/lux/world/net/uri/query.lux
index ecdd3c2c4..4ac981426 100644
--- a/stdlib/source/test/lux/world/net/uri/query.lux
+++ b/stdlib/source/test/lux/world/net/uri/query.lux
@@ -4,8 +4,9 @@
[abstract
[monad (.only do)]
[\\specification
- ["[0]S" equivalence]
- ["[0]S" codec]]]
+ ["[0]S" equivalence]]
+ ["[0]" codec
+ ["[1]T" \\test]]]
[data
[collection
["[0]" dictionary]]]
@@ -36,7 +37,7 @@
(_.for [/.equivalence]
(equivalenceS.spec /.equivalence (..random 2)))
(_.for [/.codec]
- (codecS.spec /.equivalence /.codec (..random 3)))
+ (codecT.spec /.equivalence /.codec (..random 3)))
(_.coverage [/.empty]
(dictionary.empty? /.empty))
diff --git a/stdlib/source/test/lux/world/time.lux b/stdlib/source/test/lux/world/time.lux
index 95ddb6370..4997cb844 100644
--- a/stdlib/source/test/lux/world/time.lux
+++ b/stdlib/source/test/lux/world/time.lux
@@ -5,9 +5,11 @@
[monad (.only do)]
[\\specification
["$[0]" equivalence]
- ["$[0]" order]
- ["$[0]" enum]
- ["$[0]" codec]]]
+ ["$[0]" enum]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" pipe]
["[0]" try (.use "[1]#[0]" functor)]
@@ -41,11 +43,11 @@
(_.for [/.equivalence]
($equivalence.spec /.equivalence random.time))
(_.for [/.order]
- ($order.spec /.order random.time))
+ (orderT.spec /.order random.time))
(_.for [/.enum]
($enum.spec /.enum random.time))
(_.for [/.codec]
- ($codec.spec /.equivalence /.codec random.time))))
+ (codecT.spec /.equivalence /.codec random.time))))
(def for_clock
Test
diff --git a/stdlib/source/test/lux/world/time/date.lux b/stdlib/source/test/lux/world/time/date.lux
index d2a3bdc0d..aff778c3c 100644
--- a/stdlib/source/test/lux/world/time/date.lux
+++ b/stdlib/source/test/lux/world/time/date.lux
@@ -5,9 +5,11 @@
[monad (.only do)]
[\\specification
["$[0]" equivalence]
- ["$[0]" order]
- ["$[0]" enum]
- ["$[0]" codec]]]
+ ["$[0]" enum]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" try (.use "[1]#[0]" functor)]
["[0]" exception]]
@@ -33,11 +35,11 @@
(_.for [/.equivalence]
($equivalence.spec /.equivalence random.date))
(_.for [/.order]
- ($order.spec /.order random.date))
+ (orderT.spec /.order random.date))
(_.for [/.enum]
($enum.spec /.enum random.date))
(_.for [/.codec]
- ($codec.spec /.equivalence /.codec random.date))
+ (codecT.spec /.equivalence /.codec random.date))
(do random.monad
[expected random.date]
diff --git a/stdlib/source/test/lux/world/time/day.lux b/stdlib/source/test/lux/world/time/day.lux
index 5e1c3a2fe..46b3c7785 100644
--- a/stdlib/source/test/lux/world/time/day.lux
+++ b/stdlib/source/test/lux/world/time/day.lux
@@ -6,9 +6,11 @@
[\\specification
["$[0]" equivalence]
["$[0]" hash]
- ["$[0]" order]
- ["$[0]" enum]
- ["$[0]" codec]]]
+ ["$[0]" enum]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" try (.use "[1]#[0]" functor)]
["[0]" exception]
@@ -52,11 +54,11 @@
(_.for [/.hash]
($hash.spec /.hash ..random))
(_.for [/.order]
- ($order.spec /.order ..random))
+ (orderT.spec /.order ..random))
(_.for [/.enum]
($enum.spec /.enum ..random))
(_.for [/.codec]
- ($codec.spec /.equivalence /.codec ..random))
+ (codecT.spec /.equivalence /.codec ..random))
(,, (with_template [<before> <current> <after>]
[(_.coverage [<current>]
diff --git a/stdlib/source/test/lux/world/time/duration.lux b/stdlib/source/test/lux/world/time/duration.lux
index c3546fe7a..f0e17332f 100644
--- a/stdlib/source/test/lux/world/time/duration.lux
+++ b/stdlib/source/test/lux/world/time/duration.lux
@@ -5,10 +5,13 @@
[monad (.only do)]
[\\specification
["$[0]" equivalence]
- ["$[0]" order]
- ["$[0]" enum]
- ["$[0]" monoid]
- ["$[0]" codec]]]
+ ["$[0]" enum]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]
+ ["[0]" monoid
+ ["[1]T" \\test]]]
[data
["[0]" bit (.use "[1]#[0]" equivalence)]]
[math
@@ -29,13 +32,13 @@
(_.for [/.equivalence]
($equivalence.spec /.equivalence random.duration))
(_.for [/.order]
- ($order.spec /.order random.duration))
+ (orderT.spec /.order random.duration))
(_.for [/.enum]
($enum.spec /.enum random.duration))
(_.for [/.monoid]
- ($monoid.spec /.equivalence /.monoid random.duration))
+ (monoidT.spec /.equivalence /.monoid random.duration))
(_.for [/.codec]
- ($codec.spec /.equivalence /.codec random.duration))
+ (codecT.spec /.equivalence /.codec random.duration))
(do random.monad
[duration random.duration]
diff --git a/stdlib/source/test/lux/world/time/instant.lux b/stdlib/source/test/lux/world/time/instant.lux
index ef6773eac..eebdd4fa0 100644
--- a/stdlib/source/test/lux/world/time/instant.lux
+++ b/stdlib/source/test/lux/world/time/instant.lux
@@ -6,9 +6,11 @@
[\\specification
["$[0]" equivalence]
["$[0]" hash]
- ["$[0]" order]
- ["$[0]" enum]
- ["$[0]" codec]]]
+ ["$[0]" enum]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" function]
["[0]" try (.use "[1]#[0]" functor)]
@@ -38,11 +40,11 @@
(_.for [/.hash]
($hash.spec /.hash random.instant))
(_.for [/.order]
- ($order.spec /.order random.instant))
+ (orderT.spec /.order random.instant))
(_.for [/.enum]
($enum.spec /.enum random.instant))
(_.for [/.codec]
- ($codec.spec /.equivalence /.codec random.instant))
+ (codecT.spec /.equivalence /.codec random.instant))
(do random.monad
[.let [(open "/#[0]") /.equivalence]
diff --git a/stdlib/source/test/lux/world/time/month.lux b/stdlib/source/test/lux/world/time/month.lux
index bc095c947..20d2d070e 100644
--- a/stdlib/source/test/lux/world/time/month.lux
+++ b/stdlib/source/test/lux/world/time/month.lux
@@ -6,9 +6,11 @@
[\\specification
["$[0]" equivalence]
["$[0]" hash]
- ["$[0]" order]
- ["$[0]" enum]
- ["$[0]" codec]]]
+ ["$[0]" enum]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" try (.use "[1]#[0]" functor)]
["[0]" exception]
@@ -46,11 +48,11 @@
(_.for [/.hash]
($hash.spec /.hash ..random))
(_.for [/.order]
- ($order.spec /.order ..random))
+ (orderT.spec /.order ..random))
(_.for [/.enum]
($enum.spec /.enum ..random))
(_.for [/.codec]
- ($codec.spec /.equivalence /.codec ..random))
+ (codecT.spec /.equivalence /.codec ..random))
(,, (with_template [<before> <current> <after>]
[(_.coverage [<current>]
diff --git a/stdlib/source/test/lux/world/time/solar.lux b/stdlib/source/test/lux/world/time/solar.lux
index f1da38370..5ffe2f1bd 100644
--- a/stdlib/source/test/lux/world/time/solar.lux
+++ b/stdlib/source/test/lux/world/time/solar.lux
@@ -4,9 +4,7 @@
[abstract
[monad (.only do)]
[\\specification
- ["$[0]" equivalence]
- ["$[0]" order]
- ["$[0]" codec]]]
+ ["$[0]" equivalence]]]
[control
["[0]" try]
["[0]" exception]
diff --git a/stdlib/source/test/lux/world/time/year.lux b/stdlib/source/test/lux/world/time/year.lux
index a635804ea..fc8504e80 100644
--- a/stdlib/source/test/lux/world/time/year.lux
+++ b/stdlib/source/test/lux/world/time/year.lux
@@ -4,9 +4,11 @@
[abstract
[monad (.only do)]
[\\specification
- ["$[0]" equivalence]
- ["$[0]" order]
- ["$[0]" codec]]]
+ ["$[0]" equivalence]]
+ ["[0]" codec
+ ["[1]T" \\test]]
+ ["[0]" order
+ ["[1]T" \\test]]]
[control
["[0]" try]
["[0]" exception]]
@@ -40,9 +42,9 @@
(_.for [/.equivalence]
($equivalence.spec /.equivalence ..random))
(_.for [/.order]
- ($order.spec /.order ..random))
+ (orderT.spec /.order ..random))
(_.for [/.codec /.parser]
- ($codec.spec /.equivalence /.codec ..random))
+ (codecT.spec /.equivalence /.codec ..random))
(do random.monad
[expected random.int]