aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world
diff options
context:
space:
mode:
authorEduardo Julian2022-12-11 16:07:39 -0400
committerEduardo Julian2022-12-11 16:07:39 -0400
commiteef4422b1f16be2b8c651461f2c006dc4c11f314 (patch)
tree0fa040c7a628d03551b7d7d4244a4af025d5edba /stdlib/source/test/lux/world
parentfd3f02c024687bc5c2b9741f6386719a0affb7bb (diff)
Added support for fixed-point arithmetic.
Diffstat (limited to 'stdlib/source/test/lux/world')
-rw-r--r--stdlib/source/test/lux/world/money.lux42
-rw-r--r--stdlib/source/test/lux/world/money/currency.lux4
-rw-r--r--stdlib/source/test/lux/world/net/http/response.lux2
3 files changed, 43 insertions, 5 deletions
diff --git a/stdlib/source/test/lux/world/money.lux b/stdlib/source/test/lux/world/money.lux
index 4ebd46bf2..4cddc38ee 100644
--- a/stdlib/source/test/lux/world/money.lux
+++ b/stdlib/source/test/lux/world/money.lux
@@ -4,10 +4,12 @@
[abstract
[monad (.only do)]
[\\specification
- ["[0]S" equivalence]]]
+ ["[0]S" equivalence]
+ ["[0]S" order]]]
[control
["[0]" maybe (.use "[1]#[0]" functor)]]
[data
+ ["[0]" bit (.use "[1]#[0]" equivalence)]
["[0]" text (.only)
["%" \\format]]]
[math
@@ -41,8 +43,10 @@
expected_subject random.nat])
(_.for [/.Money])
(all _.and
- (_.for [/.equivalence]
+ (_.for [/.equivalence /.=]
(equivalenceS.spec /.equivalence ..random))
+ (_.for [/.order /.<]
+ (orderS.spec /.order ..random))
(_.coverage [/.money /.currency /.amount]
(let [it (/.money expected_currency expected_amount)]
@@ -60,6 +64,40 @@
(/.- parameter)
(maybe#each (of /.equivalence = subject))
(maybe.else false)))))
+ (_.coverage [/.min]
+ (let [expected_parameter (/.money expected_currency expected_parameter)
+ expected_subject (/.money expected_currency expected_subject)]
+ (and (/.<= expected_parameter
+ (/.min expected_parameter expected_subject))
+ (/.<= expected_subject
+ (/.min expected_parameter expected_subject)))))
+ (_.coverage [/.max]
+ (let [expected_parameter (/.money expected_currency expected_parameter)
+ expected_subject (/.money expected_currency expected_subject)]
+ (and (/.>= expected_parameter
+ (/.max expected_parameter expected_subject))
+ (/.>= expected_subject
+ (/.max expected_parameter expected_subject)))))
+ (let [expected_parameter (/.money expected_currency expected_parameter)
+ expected_subject (/.money expected_currency 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 (/.money expected_currency expected_amount)
+ actual (/.money expected_currency (n.+ (/.units expected)
+ (/.sub_units expected)))]
+ (/.= expected actual)))
+ (_.coverage [/.of_units /.of_sub_units]
+ (let [expected (/.money expected_currency expected_amount)
+ actual (/.+ (/.of_units expected_currency (/.units expected))
+ (/.of_sub_units expected_currency (/.sub_units expected)))]
+ (/.= expected actual)))
(do !
[it ..random]
(_.coverage [/.format]
diff --git a/stdlib/source/test/lux/world/money/currency.lux b/stdlib/source/test/lux/world/money/currency.lux
index 927ffd8f3..eeb59e9fc 100644
--- a/stdlib/source/test/lux/world/money/currency.lux
+++ b/stdlib/source/test/lux/world/money/currency.lux
@@ -240,8 +240,8 @@
(set.of_list n.hash))]
(n.= (list.size options)
(set.size uniques))))
- (_.coverage [/.subdivisions]
- (list.every? (|>> /.subdivisions (n.> 0))
+ (_.coverage [/.sub_divisions]
+ (list.every? (|>> /.sub_divisions (n.> 0))
options))
)))
(<| (_.for [/.currency /.type])
diff --git a/stdlib/source/test/lux/world/net/http/response.lux b/stdlib/source/test/lux/world/net/http/response.lux
index d25d3ce7f..bd3ee75aa 100644
--- a/stdlib/source/test/lux/world/net/http/response.lux
+++ b/stdlib/source/test/lux/world/net/http/response.lux
@@ -11,7 +11,7 @@
["[0]" product]
["[0]" binary (.use "[1]#[0]" equivalence)]
["[0]" color
- [named
+ [rgb
["[1]T" \\test]]]
["[0]" text (.use "[1]#[0]" equivalence)
[encoding