aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/ffi/node_js.js.lux
blob: 82aff3f75cfdaff55028016b22a9bae1d65b18b3 (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
38
39
40
41
42
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try]
    ["[0]" exception]]
   [math
    ["[0]" random]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(def .public test
  Test
  (do [! random.monad]
    [real_module (all random.either
                      (in "buffer")
                      (in "fs")
                      (in "net")
                      (in "os"))
     fake_module (random.upper_case 1)]
    (<| (_.covering /._)
        (all _.and
             (_.coverage [/.require]
               (when [(/.require real_module)
                      (/.require real_module)]
                 [{try.#Success left} {try.#Success right}]
                 (same? left right)

                 _
                 false))
             (_.coverage [/.cannot_require]
               (when (/.require fake_module)
                 {try.#Failure error}
                 (exception.match? /.cannot_require error)

                 _
                 false))
             ))))