aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/lux/abstract/enum.lux
blob: a5118918af2f140c924b7ab3593c29459fb14967 (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
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]]
    [math
     ["." random (#+ Random)]]]]
  [\\library
   ["." /]])

(def: .public (spec (^open "\.") gen_sample)
  (All (_ a) (-> (/.Enum a) (Random a) Test))
  (do random.monad
    [sample gen_sample]
    (<| (_.for [/.Enum])
        ($_ _.and
            (_.test "Successor and predecessor are inverse functions."
                    (and (\= (|> sample \succ \pred)
                             sample)
                         (\= (|> sample \pred \succ)
                             sample)
                         (not (\= (\succ sample)
                                  sample))
                         (not (\= (\pred sample)
                                  sample))))
            ))))