blob: c2fb768b254489ae8653a3072e72b6901dd69855 (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
(.using
[library
[lux "*"
["_" test {"+" Test}]
[abstract
[monad {"+" do}]]
[control
["[0]" pipe]
["[0]" try ("[1]#[0]" functor)]
[concurrency
["[0]" async]]
[parser
["<[0]>" binary]]]
[data
["[0]" product]
["[0]" binary {"+" Binary} ("[1]#[0]" equivalence)]
["[0]" bit ("[1]#[0]" equivalence)]
[format
["[0]" tar]]
["[0]" text ("[1]#[0]" equivalence)
["%" format {"+" format}]
[encoding
["[0]" utf8]]]
[collection
["[0]" sequence]]]
[math
["[0]" random {"+" Random}]
[number
["n" nat]]]
[world
["[0]" file]]]]
[\\library
["[0]" /
[//
["[0]" io "_"
["[1]" context]]]]])
(def: .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[.let [/ .module_separator]
source/0 (random.lower_case 1)
source/1 (random.lower_case 2)
target (random.lower_case 3)
.let [random_file (is (Random file.Path)
(# ! each (text.suffix io.lux_extension) (random.lower_case 4)))]
file/0' random_file
.let [file/0 (format source/0 / file/0')]
dir/0 (random.lower_case 5)
file/1' (# ! each (|>> (format dir/0 /)) random_file)
.let [file/1 (format source/1 / file/1')]
.let [random_content (is (Random Binary)
(# ! each (|>> %.nat (# utf8.codec encoded)) random.nat))]
content/0 random_content
content/1 random_content]
(all _.and
(in (do [! async.monad]
[it (do (try.with !)
[.let [fs (file.mock /)]
_ (# fs make_directory source/0)
_ (# fs write file/0 content/0)
_ (# fs make_directory source/1)
_ (# fs make_directory (format source/1 / dir/0))
_ (# fs write file/1 content/1)
_ (# fs make_directory target)
library_tar (/.library fs (list source/0 source/1))
_ (/.export fs [(list source/0 source/1) target])
export_tar (# fs read (format target / /.file))
export_tar (# ! in (<binary>.result tar.parser export_tar))]
(in [library_tar export_tar]))]
(all _.and'
(_.coverage' [/.library /.mode /.ownership]
(|> it
(try#each (|>> product.left
sequence.list
(pipe.case
(pattern (list {tar.#Normal [actual_path/0 when/0 mode/0 ownership/0 actual_content/0]}
{tar.#Normal [actual_path/1 when/1 mode/1 ownership/1 actual_content/1]}))
(with_expansions [<test> (and (and (text#= file/0' (tar.from_path actual_path/0))
(same? /.mode mode/0)
(same? /.ownership ownership/0)
(binary#= content/0 (tar.data actual_content/0)))
(and (text#= file/1' (tar.from_path actual_path/1))
(same? /.mode mode/1)
(same? /.ownership ownership/1)
(binary#= content/1 (tar.data actual_content/1))))]
(or <test>
(let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
[[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
<test>)))
_
false)))
(try.else false)))
(_.coverage' [/.export /.file]
(|> it
(try#each (|>> product.right
sequence.list
(pipe.case
(pattern (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
{tar.#Normal [actual_path/1 _ _ _ actual_content/1]}))
(with_expansions [<test> (and (and (text#= file/0' (tar.from_path actual_path/0))
(binary#= content/0 (tar.data actual_content/0)))
(and (text#= file/1' (tar.from_path actual_path/1))
(binary#= content/1 (tar.data actual_content/1))))]
(or <test>
(let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
[[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
<test>)))
_
false)))
(try.else false)))
)))
))))
|