aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/command/pom.lux
blob: b564b0dbc4aeaee425f779a82d9f4ecd5c7db55e (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try (.use "[1]#[0]" functor)]
    [concurrency
     ["[0]" async]]]
   [data
    ["[0]" binary (.use "[1]#[0]" equivalence)]
    ["[0]" text (.use "[1]#[0]" equivalence)
     [encoding
      ["[0]" utf8]]]
    [format
     ["[0]" xml]]]
   [math
    ["[0]" random]]
   [world
    ["[0]" file]]
   [test
    ["[0]" unit]
    ["_" property (.only Test)]]]]
 [//
  ["@[0]" version]
  [//
   ["@[0]" profile]]]
 [\\program
  ["[0]" / (.only)
   ["//[1]" ///
    ["[1]" profile]
    ["[1][0]" action]
    ["[1][0]" pom]]]])

(def .public test
  Test
  (<| (_.covering /._)
      (do random.monad
        [sample @profile.random
         .let [fs (file.mock (of file.default separator))]]
        (in (do [! async.monad]
              [.let [console (@version.echo "")]
               outcome (/.do! console fs sample)]
              (when outcome
                {try.#Success _}
                (do !
                  [verdict (do ///action.monad
                             [expected (|> (///pom.write sample)
                                           (try#each (|>> (of xml.codec encoded)
                                                          (of utf8.codec encoded)))
                                           (of ! in))
                              actual (of fs read ///pom.file)

                              logging! (of ///action.monad each
                                           (text#= /.success)
                                           (of console read_line []))

                              .let [expected_content!
                                    (binary#= expected actual)]]
                             (in (and logging!
                                      expected_content!)))]
                  (unit.coverage [/.do! /.success]
                    (try.else false verdict)))
                
                {try.#Failure error}
                (unit.coverage [/.do!]
                  (when (the ///.#identity sample)
                    {.#Some _}
                    false

                    {.#None}
                    true))))))))