blob: 6a3c48a99d07eb7a5d9f55a75d67568d654e4222 (
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
|
(.require
[library
[lux (.except)
[abstract
[monad (.only do)]]
[control
["|" pipe]
["[0]" try (.use "[1]#[0]" functor)]
["[0]" exception]]
[data
["[0]" text (.use "[1]#[0]" equivalence)]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]
[number
["[0]" nat (.use "[1]#[0]" equivalence)]]]
[test
["_" property (.only Test)]]]]
[\\library
["[0]" / (.only)
[//
["[0]" mime (.use "[1]#[0]" equivalence)]]]])
(def .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[expected_content_length random.nat
expected_content_type (random.either (random#in mime.javascript)
(random#in mime.jpeg))
expected_location (random.either (random#in "http://example.com/yolo")
(random#in "http://example.com/meme"))
header_name (random.lower_case 1)
expected_header_value (random.upper_case 1)
.let [header (is (/.Header Text)
[/.#name header_name
/.#in (|>>)
/.#out (|>> {try.#Success})])]])
(all _.and
(_.coverage [/.Headers /.empty /.unknown]
(|> /.empty
(/.one header)
(|.when
{try.#Success _}
false
{try.#Failure error}
(exception.match? /.unknown error))))
(_.coverage [/.Header /.#name /.#in /.#out
/.has /.one]
(|> /.empty
(/.has header expected_header_value)
(/.one header)
(try#each (same? expected_header_value))
(try.else false)))
(_.coverage [/.content_length]
(|> /.empty
(/.has /.content_length expected_content_length)
(/.one /.content_length)
(try#each (nat#= expected_content_length))
(try.else false)))
(_.coverage [/.content_type]
(|> /.empty
(/.has /.content_type expected_content_type)
(/.one /.content_type)
(try#each (mime#= expected_content_type))
(try.else false)))
(_.coverage [/.location]
(|> /.empty
(/.has /.location expected_location)
(/.one /.location)
(try#each (text#= expected_location))
(try.else false)))
)))
|