aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler/arity.lux
blob: 24f37277e2d799354bce3de2d69910e2b8c1568e (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
29
(.using
 [library
  [lux (.full)
   ["_" test (.only Test)]
   [abstract
    [monad (.only do)]]
   [data
    ["[0]" bit ("[1]#[0]" equivalence)]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["n" nat]]]]]
 [\\library
  ["[0]" /]])

(def: .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Arity])
      (do [! random.monad]
        [arity (# ! each (n.% 3) random.nat)]
        (all _.and
             (_.coverage [/.nullary?]
               (bit#= (n.= 0 arity) (/.nullary? arity)))
             (_.coverage [/.unary?]
               (bit#= (n.= 1 arity) (/.unary? arity)))
             (_.coverage [/.multiary?]
               (bit#= (n.>= 2 arity) (/.multiary? arity)))
             ))))