aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/math/number/i8.lux
blob: b0903a903f5a9e0336ea0f1ef852e7b21b310916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [monad (#+ do)]
    {[0 #spec]
     [/
      ["$." equivalence]]}]
   [math
    ["." random (#+ Random)]]]
  {1
   ["." /
    ["/#" // #_
     ["i" int]
     ["#." i64]]]})

(def: #export random
  (Random /.I8)
  (\ random.functor map /.i8 random.i64))

(def: #export test
  Test
  (<| (_.covering /._)
      (_.for [/.I8])
      (do {! random.monad}
        [#let [limit (|> (dec /.width)
                         //i64.mask
                         .int
                         inc)]
         expected (\ ! map (i.% limit) random.int)]
        ($_ _.and
            (_.for [/.equivalence]
                   ($equivalence.spec /.equivalence ..random))
            
            (_.cover [/.i8 /.i64 /.width]
                     (let [actual (|> expected .i64 /.i8 /.i64)]
                       (\ //i64.equivalence = expected actual)))
            ))))