aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/net/mime.lux
blob: 18f6521c1729effb44eeb59eed71176a7c4bca29 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]
    ["[0]" equivalence
     ["[1]T" \\test]]
    [\\specification
     ["[0]S" hash]]]
   [data
    ["[0]" text (.only)
     ["[0]" encoding (.only)
      ["[1]T" \\test]]]
    [collection
     ["[0]" list]
     ["[0]" set]]]
   [math
    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
    [number
     ["n" nat]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(with_expansions [<randoms> (with_template [<name> <options>]
                              [(def <name>
                                 (Random /.MIME)
                                 (`` (all random.either
                                          (,, (with_template [<type>]
                                                [(random#in <type>)]
                                                
                                                <options>))
                                          )))]

                              [random/0 <options/0>]
                              [random/1 <options/1>]
                              [random/2 <options/2>]
                              [random/3 <options/3>]
                              )
                  <coverages> (with_template [<options>]
                                [(`` (_.coverage [(,, (with_template [<type>]
                                                        [<type>]
                                                        
                                                        <options>
                                                        ))]
                                       (let [uniques (set.of_list /.hash ..options)]
                                         (n.= (list.size ..options)
                                              (set.size uniques)))))]

                                [<options/0>]
                                [<options/1>]
                                [<options/2>]
                                [<options/3>]
                                )
                  <all_options> (with_template [<options>]
                                  [(is (List /.MIME)
                                       (let [options (is (-> Any (List /.MIME))
                                                         (function (_ _)
                                                           (list <options>)))]
                                         (options [])))]

                                  [<options/0>]
                                  [<options/1>]
                                  [<options/2>]
                                  [<options/3>]
                                  )
                  <options/0> (these [/.aac]
                                     [/.abiword]
                                     [/.avi]
                                     [/.amazon_kindle_ebook]
                                     [/.binary]
                                     [/.bitmap]
                                     [/.bzip]
                                     [/.bzip2]
                                     [/.c_shell]
                                     [/.css]
                                     [/.csv]
                                     [/.microsoft_word]
                                     [/.microsoft_word_openxml]
                                     [/.ms_embedded_opentype_fonts]
                                     [/.epub]
                                     [/.ecmascript]
                                     [/.gif]
                                     [/.html]
                                     [/.icon]
                                     [/.icalendar]
                                     [/.jar]
                                     [/.jpeg]
                                     [/.javascript]
                                     [/.json]
                                     [/.midi]
                                     [/.mpeg])
                  <options/1> (these [/.apple_installer_package]
                                     [/.opendocument_presentation]
                                     [/.opendocument_spreadsheet]
                                     [/.opendocument_text]
                                     [/.ogg_audio]
                                     [/.ogg_video]
                                     [/.ogg]
                                     [/.opentype_font]
                                     [/.png]
                                     [/.pdf]
                                     [/.microsoft_powerpoint]
                                     [/.microsoft_powerpoint_openxml]
                                     [/.rar]
                                     [/.rtf]
                                     [/.bourne_shell]
                                     [/.svg]
                                     [/.flash])
                  <options/2> (these [/.tar]
                                     [/.tiff]
                                     [/.typescript]
                                     [/.truetype_font]
                                     [/.microsoft_visio]
                                     [/.wav]
                                     [/.webm_audio]
                                     [/.webm_video]
                                     [/.webp]
                                     [/.woff]
                                     [/.woff2]
                                     [/.xhtml]
                                     [/.microsoft_excel]
                                     [/.microsoft_excel_openxml]
                                     [/.xml]
                                     [/.xul]
                                     [/.zip])
                  <options/3> (these [/.audio_3gpp]
                                     [/.video_3gpp]
                                     [/.audio_3gpp2]
                                     [/.video_3gpp2]
                                     [/.compressed_7z]

                                     [/.form]
                                     [/.multi_part_form]

                                     [/.utf_8])]
  <randoms>

  (def .public random
    (Random /.MIME)
    (all random.either
         ..random/0
         ..random/1
         ..random/2
         ))

  (def options
    (List /.MIME)
    (list.together (list <all_options>)))
  
  (def .public test
    Test
    (<| (_.covering /._)
        (do [! random.monad]
          [expected ..random
           encoding encodingT.random])
        (_.for [/.MIME])
        (all _.and
             (_.for [/.equivalence]
                    (equivalenceT.spec /.equivalence ..random))
             (_.for [/.hash]
                    (hashS.spec /.hash ..random))

             (_.coverage [/.mime /.name]
               (|> expected
                   /.name
                   /.mime
                   (of /.equivalence = expected)))
             <coverages>
             (_.coverage [/.text]
               (|> (/.text encoding)
                   /.name
                   (text.contains? (encoding.name encoding))))
             )))
  )