aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/test/coverage.lux
blob: 795f957d79a625b60b255333cc3acaabec832cd2 (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
43
44
45
46
47
(.require
 [library
  [lux (.except of)
   [abstract
    [monad (.only do)]]
   [data
    ["[0]" text (.only)
     ["%" \\format]]
    [collection
     ["[0]" list (.use "[1]#[0]" mix functor)]
     ["[0]" set (.only Set)]]]
   ["[0]" meta (.only)
    ["[0]" symbol]
    ["[0]" code (.only)
     ["<[1]>" \\parser]]
    [macro
     [syntax (.only syntax)]]]]])

(type .public Coverage
  (Set Symbol))

(def .public of
  (let [symbol (is (-> Symbol Code)
                   (function (_ symbol)
                     (` (is Symbol
                            [(, (code.text (symbol.module symbol)))
                             (, (code.text (symbol.short symbol)))]))))]
    (syntax (_ [name <code>.global])
      (do meta.monad
        [_ (meta.export name)]
        (in (list (symbol name)))))))

(def separator
  Text
  (text.of_char 31))

(def .public encoded
  (-> (List Text) Text)
  (text.interposed ..separator))

(def .public (decoded module encoding)
  (-> Text Text Coverage)
  (|> encoding
      (text.all_split_by ..separator)
      (list#mix (function (_ short it)
                  (set.has [module short] it))
                (set.empty symbol.hash))))