blob: 9ee4b6e1d11f16653d03b11486f56ab089f93732 (
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
|
(.require
[library
[lux (.except)
[abstract
[monad (.only do)]
["[0]" equivalence
["[1]T" \\test]]]
[control
["[0]" try (.use "[1]#[0]" functor)]
["[0]" exception]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" functor)]
[number
["f" frac]]]
[test
["_" property (.only Test)]]]]
[\\library
["[0]" / (.only)
[//
["[0]" rgb]]]]
[//
["[0]T" rgb]])
(def .public value
(Random /.Value)
(random#each /.value random.safe_frac))
(def .public random
(Random /.CMYK)
(do random.monad
[cyan ..value
magenta ..value
yellow ..value
key ..value]
(in [/.#cyan cyan
/.#magenta magenta
/.#yellow yellow
/.#key key])))
(def .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[expected_value ..value
expected_rgb rgbT.random
expected_cmyk ..random
possible_value random.frac
.let [delta +0.000000001]])
(all _.and
(_.for [/.Value]
(all _.and
(_.coverage [/.value?]
(and (/.value? expected_value)
(not (/.value? (f.+ delta /.most)))
(not (/.value? (f.- delta /.least)))))
(_.coverage [/.value]
(if (/.value? possible_value)
(|> possible_value
/.value
(f.= possible_value))
(or (f.= /.least (/.value possible_value))
(f.= /.most (/.value possible_value)))))
(_.coverage [/.least]
(and (f.< /.most
/.least)
(/.value? /.least)
(/.value? (f.+ delta /.least))
(not (/.value? (f.- delta /.least)))))
(_.coverage [/.most]
(and (f.> /.least
/.most)
(/.value? /.most)
(/.value? (f.- delta /.most))
(not (/.value? (f.+ delta /.most)))))
))
(_.for [/.CMYK
/.#cyan /.#magenta /.#yellow /.#key]
(all _.and
(_.for [/.equivalence]
(equivalenceT.spec /.equivalence ..random))
(_.coverage [/.of_rgb /.rgb]
(|> expected_rgb
/.of_rgb
/.rgb
(of rgb.equivalence = expected_rgb)))
))
)))
|