aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/math/number/i8.lux
blob: eb36cd7017f7531f283113e6817467cd899c780e (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
39
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]
    ["[0]" equivalence
     ["[1]T" \\test]]]
   [math
    ["[0]" random (.only Random)]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" / (.only)
   ["/[1]" //
    ["i" int]
    ["[1][0]" i64]]]])

(def .public random
  (Random /.I8)
  (of random.functor each /.i8 random.i64))

(def .public test
  Test
  (<| (_.covering /._)
      (_.for [/.I8])
      (do [! random.monad]
        [.let [limit (|> (-- /.width)
                         //i64.mask
                         .int
                         ++)]
         expected (of ! each (i.% limit) random.int)]
        (all _.and
             (_.for [/.equivalence]
                    (equivalenceT.spec /.equivalence ..random))
             
             (_.coverage [/.i8 /.i64 /.width]
               (let [actual (|> expected .i64 /.i8 /.i64)]
                 (of //i64.equivalence = expected actual)))
             ))))