blob: e86efa6dddb758ef6972ecdb3861b99fc0d3dba8 (
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
|
(.module:
[library
[lux #*
["_" test (#+ Test)]
[abstract
[monad (#+ do)]]
[control
["." try (#+ Try)]
[concurrency
["." async (#+ Async)]]]
[data
[text
["%" format]
[encoding
["." utf8]]]
[collection
["." set (#+ Set)]]]
[math
["." random]]
[world
["." file]]]]
[//
["$." profile]]
[\\program
["." /
["/#" // #_
["#" profile (#+ Profile)]
["#." project]
["#." action]
["#." format]
[repository
[remote (#+ Address)]]]]])
(def: (with_default_source sources)
(-> (Set //.Source) (Set //.Source))
(if (set.empty? sources)
(set.add //.default_source sources)
sources))
(def: with_default_repository
(-> (Set Address) (Set Address))
(set.add //.default_repository))
(def: #export test
Test
(<| (_.covering /._)
(do {! random.monad}
[expected (\ ! map (set@ #//.parents (list)) $profile.random)
#let [fs (: (file.System Async)
(file.mock (\ file.default separator)))]]
(in (do async.monad
[verdict (do //action.monad
[#let [profile (|> expected
//format.profile
%.code
(\ utf8.codec encode))]
_ (\ fs write profile //project.file)
actual (: (Async (Try Profile))
(/.read async.monad fs //.default))]
(in (\ //.equivalence =
(|> expected
(update@ #//.sources ..with_default_source)
(update@ #//.repositories ..with_default_repository))
actual)))]
(_.cover' [/.read]
(try.else false verdict)))))))
|