aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/lux/abstract/enum.lux
blob: f510a345eae50e855c443d7ae18bf0efd28a8df3 (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
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [math
    ["[0]" random (.only Random)]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(def .public (spec (open "_#[0]") gen_sample)
  (All (_ a) (-> (/.Enum a) (Random a) Test))
  (do random.monad
    [sample gen_sample]
    (<| (_.for [/.Enum])
        (all _.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))))
             ))))