aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/lux/abstract/enum.lux
blob: 198d3da5056da700d3d9eebde359276b03296914 (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
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [monad (#+ do)]]
   [math
    ["." random (#+ Random)]]]
  {1
   ["." /]})

(def: #export (spec (^open "/@.") gen-sample)
  (All [a] (-> (/.Enum a) (Random a) Test))
  (do random.monad
    [sample gen-sample]
    (<| (_.with-cover [/.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))))
            ))))