aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/number/frac.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/data/number/frac.lux69
1 files changed, 31 insertions, 38 deletions
diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux
index 319debddd..87b937a93 100644
--- a/stdlib/source/test/lux/data/number/frac.lux
+++ b/stdlib/source/test/lux/data/number/frac.lux
@@ -9,8 +9,6 @@
["$." equivalence]
["$." order]
["$." number]
- ["$." enum]
- ["$." interval]
["$." monoid]
["$." codec]]}]
[math
@@ -21,40 +19,35 @@
(def: #export test
Test
- (<| (_.context (%name (name-of .Frac)))
- ($_ _.and
- ($equivalence.spec /.equivalence r.frac)
- ($order.spec /.order r.frac)
- ($number.spec /.order /.number r.frac)
- ($enum.spec /.enum r.frac)
- ($interval.spec /.interval r.frac)
- (<| (_.context "Addition.")
- ($monoid.spec /.equivalence /.addition r.frac))
- (<| (_.context "Multiplication.")
- ($monoid.spec /.equivalence /.multiplication r.frac))
- (<| (_.context "Minimum.")
- ($monoid.spec /.equivalence /.minimum r.frac))
- (<| (_.context "Maximum.")
- ($monoid.spec /.equivalence /.multiplication r.frac))
- ## TODO: Uncomment ASAP
- ## (<| (_.context "Binary.")
- ## ($codec.spec /.equivalence /.binary r.frac))
- ## (<| (_.context "Octal.")
- ## ($codec.spec /.equivalence /.octal r.frac))
- ## (<| (_.context "Decimal.")
- ## ($codec.spec /.equivalence /.decimal r.frac))
- ## (<| (_.context "Hexadecimal.")
- ## ($codec.spec /.equivalence /.hex r.frac))
+ (let [gen-frac (:: r.monad map (|>> (i/% +100) .int-to-frac) r.int)]
+ (<| (_.context (%name (name-of /._)))
+ (`` ($_ _.and
+ ($equivalence.spec /.equivalence gen-frac)
+ ($order.spec /.order gen-frac)
+ ($number.spec /.order /.number gen-frac)
+ (~~ (do-template [<monoid>]
+ [(<| (_.context (%name (name-of <monoid>)))
+ ($monoid.spec /.equivalence <monoid> gen-frac))]
- (_.test "Alternate notations."
- (and (f/= (bin "+1100.1001")
- (bin "+11,00.10,01"))
- (f/= (oct "-6152.43")
- (oct "-615,2.43"))
- (f/= (hex "+deadBE.EF")
- (hex "+dead,BE.EF"))))
- (do r.monad
- [sample r.frac]
- (_.test "Can convert frac values to/from their bit patterns."
- (|> sample /.frac-to-bits /.bits-to-frac (f/= sample))))
- )))
+ [/.addition] [/.multiplication] [/.minimum] [/.maximum]
+ ))
+ ## TODO: Uncomment ASAP
+ ## (~~ (do-template [<codec>]
+ ## [(<| (_.context (%name (name-of /.binary)))
+ ## ($codec.spec /.equivalence <codec> gen-frac))]
+
+ ## [/.binary] [/.octal] [/.decimal] [/.hex]
+ ## ))
+
+ (_.test "Alternate notations."
+ (and (f/= (bin "+1100.1001")
+ (bin "+11,00.10,01"))
+ (f/= (oct "-6152.43")
+ (oct "-615,2.43"))
+ (f/= (hex "+deadBE.EF")
+ (hex "+dead,BE.EF"))))
+ (do r.monad
+ [sample gen-frac]
+ (_.test (format (%name (name-of /.frac-to-bits)) " " (%name (name-of /.bits-to-frac)))
+ (|> sample /.frac-to-bits /.bits-to-frac (f/= sample))))
+ )))))