aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/number/i8.lux
blob: 7cd4a5149d81d5ab071bf23f6bc72ac4569d7c8a (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
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [data
    ["." name]
    ["%" text/format (#+ format)]]
   [abstract
    [monad (#+ do)]
    {[0 #test]
     [/
      ["$." equivalence]]}]
   [math
    ["r" random (#+ Random)]]]
  {1
   ["." /
    ["/#" // #_
     ["#." i64 (#+ Mask)]]]})

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

(def: mask
  Mask
  (//i64.or //i64.sign
            (//i64.mask 7)))

(def: #export test
  Test
  (<| (_.context (name.module (name-of /._)))
      (do {@ r.monad}
        [expected (:: @ map (|>> (//i64.and ..mask) (: I64)) r.i64)]
        ($_ _.and
            ($equivalence.spec /.equivalence ..i8)
            
            (_.test "Can convert between I64 and I8"
                    (let [actual (|> expected /.i8 /.i64)]
                      (:: //i64.equivalence = expected actual)))
            ))))