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

(def: #export (spec (^open "/@.") gen-sample)
  (All [a] (-> (/.Interval a) (Random a) Test))
  (<| (_.with-cover [/.Interval])
      (do random.monad
        [sample gen-sample]
        ($_ _.and
            (_.test "No value is bigger than the top."
                    (/@< /@top sample))
            (_.test "No value is smaller than the bottom."
                    (order.> /@&order /@bottom sample))
            ))))