aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/lux/abstract/equivalence.lux
blob: f3d97e5b64eec5e30123baa24cf04a8e704bea7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [monad (#+ do)]]
   [math
    ["." random (#+ Random)]]]
  {1
   ["." / (#+ Equivalence)]})

(def: #export (spec (^open "_//.") random)
  (All [a] (-> (Equivalence a) (Random a) Test))
  (do random.monad
    [left random
     right random]
    (<| (_.for [/.Equivalence])
        ($_ _.and
            (_.test "Reflexivity."
                    (_//= left left))
            (_.test "Symmetry."
                    (if (_//= left right)
                      (_//= right left)
                      (not (_//= right left))))))))