aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux
blob: 30dd30486722816f04113fdce5e942d39034170f (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(.using
 [library
  [lux (.except)
   ["_" test (.only Test)]
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try]
    ["[0]" exception]
    [concurrency
     ["[0]" async (.only Async) (.open: "[1]#[0]" monad)]]]
   [math
    ["[0]" random]]
   [world
    ["[0]" file]]]]
 [\\library
  ["[0]" /]]
 ["$[0]" ///
  ["[1][0]" context]])

(`` (implementation: (bad it)
      (-> (file.System Async) (file.System Async))

      (~~ (with_template [<name>]
            [(def: <name>
               (at it <name>))]

            [separator]
            [file?]
            [directory?]
            [modify]
            [write]
            [append]
            [move]
            [directory_files]
            [sub_directories]
            [file_size]
            [last_modified]
            [can_execute?]
            [read]
            [delete]
            ))

      (def: (make_directory path)
        (async#in {try.#Failure ""}))
      ))

(def: .public test
  Test
  (<| (_.covering /._)
      (do [! random.monad]
        [context $///context.random
         @module random.nat]
        (all _.and
             (in (do [! async.monad]
                   [.let [/ "/"
                          fs (file.mock /)]
                    pre/0 (at fs directory? (/.path fs context @module))
                    pre/1 (/.enabled? fs context @module)
                    outcome (/.enable! ! fs context @module)
                    post/0 (at fs directory? (/.path fs context @module))
                    post/1 (/.enabled? fs context @module)]
                   (_.coverage' [/.path /.enabled? /.enable!]
                     (and (not pre/0)
                          (not pre/1)
                          
                          (case outcome
                            {try.#Success _} true
                            {try.#Failure _} false)
                          
                          post/0
                          post/1))))
             (in (do [! async.monad]
                   [.let [/ "/"
                          fs (file.mock /)]
                    pre/0 (at fs directory? (/.path fs context @module))
                    pre/1 (/.enabled? fs context @module)
                    outcome (/.enable! ! (..bad fs) context @module)
                    post/0 (at fs directory? (/.path fs context @module))
                    post/1 (/.enabled? fs context @module)]
                   (_.coverage' [/.cannot_enable]
                     (and (not pre/0)
                          (not pre/1)
                          
                          (case outcome
                            {try.#Success _}
                            false
                            
                            {try.#Failure error}
                            (exception.match? /.cannot_enable error))
                          
                          (not post/0)
                          (not post/1)))))
             ))))