aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/abstract/apply.lux
blob: 1f315c131609c4c325e0cbb0b117eecdecb9f21f (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
30
31
32
33
34
35
36
37
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" maybe]]
   [data
    [collection
     ["[0]" list]]]
   [math
    ["[0]" random]
    [number
     ["n" nat]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" / (.only Apply)]])

(def .public test
  Test
  (do random.monad
    [left random.nat
     right random.nat]
    (<| (_.covering /._)
        (all _.and
             (_.coverage [/.composite]
               (let [expected (n.+ left right)]
                 (when (of (/.composite maybe.monad maybe.apply list.apply) on
                           {.#Some (list right)}
                           {.#Some (list (n.+ left))})
                   {.#Some (list actual)}
                   (n.= expected actual)

                   _
                   false)))
             ))))