aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/number/nat.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/data/number/nat.lux')
-rw-r--r--stdlib/source/test/lux/data/number/nat.lux130
1 files changed, 0 insertions, 130 deletions
diff --git a/stdlib/source/test/lux/data/number/nat.lux b/stdlib/source/test/lux/data/number/nat.lux
deleted file mode 100644
index a2d0fd655..000000000
--- a/stdlib/source/test/lux/data/number/nat.lux
+++ /dev/null
@@ -1,130 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." hash]
- ["$." order]
- ["$." enum]
- ["$." interval]
- ["$." monoid]
- ["$." codec]]}]
- [data
- ["." bit ("#\." equivalence)]
- [number
- ["f" frac]]]
- [math
- ["." random]]]
- {1
- ["." /]})
-
-(def: signature
- Test
- (`` ($_ _.and
- (_.for [/.equivalence /.=]
- ($equivalence.spec /.equivalence random.nat))
- (_.for [/.hash]
- ($hash.spec /.hash random.nat))
- (_.for [/.order /.<]
- ($order.spec /.order random.nat))
- (_.for [/.enum]
- ($enum.spec /.enum random.nat))
- (_.for [/.interval]
- ($interval.spec /.interval random.nat))
- (~~ (template [<compose> <monoid>]
- [(_.for [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> random.nat))]
-
- [/.+ /.addition]
- [/.* /.multiplication]
-
- [/.min /.minimum]
- [/.max /.maximum]
- ))
- (~~ (template [<codec>]
- [(_.for [<codec>]
- ($codec.spec /.equivalence <codec> random.nat))]
-
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
- )))
-
-(def: predicate
- Test
- (do {! random.monad}
- [sample random.nat]
- ($_ _.and
- (_.cover [/.even? /.odd?]
- (bit\= (/.even? sample)
- (not (/.odd? sample))))
- )))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [.Nat])
- ($_ _.and
- (do random.monad
- [sample random.nat]
- ($_ _.and
- (_.cover [/.-]
- (and (/.= 0 (/.- sample sample))
- (/.= sample (/.- 0 sample))))
- (_.cover [/./]
- (and (/.= 1 (/./ sample sample))
- (/.= sample (/./ 1 sample))))
- ))
- (do random.monad
- [left random.nat
- right random.nat]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- (do random.monad
- [left (random.filter (|>> (/.= 0) not)
- random.nat)
- right random.nat]
- ($_ _.and
- (_.cover [/.%]
- (let [rem (/.% left right)
- div (|> right (/.- rem) (/./ left))]
- (/.= right
- (|> div (/.* left) (/.+ rem)))))
- (_.cover [/./%]
- (let [[div rem] (/./% left right)]
- (and (/.= div (/./ left right))
- (/.= rem (/.% left right)))))
- ))
- (do {! random.monad}
- [#let [random (\ ! map (|>> (/.% 1,000) inc) random.nat)]
- left random
- right random]
- ($_ _.and
- (_.cover [/.gcd]
- (let [gcd (/.gcd left right)]
- (and (/.= 0 (/.% gcd left))
- (/.= 0 (/.% gcd right)))))
- (_.cover [/.co-prime?]
- (bit\= (/.= 1 (/.gcd left right))
- (/.co-prime? left right)))
- (_.cover [/.lcm]
- (let [lcm (/.lcm left right)]
- (and (/.= 0 (/.% left lcm))
- (/.= 0 (/.% right lcm)))))
- ))
- (do {! random.monad}
- [expected (\ ! map (/.% 1,000,000) random.nat)]
- (_.cover [/.frac]
- (|> expected /.frac f.nat (/.= expected))))
-
- ..predicate
- ..signature
- )))