aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/net/mime.lux
blob: c1116ad5a78c0af8e6b43a45b0a14adfcff28b82 (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
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]
    [\\specification
     ["[0]S" equivalence]
     ["[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 [<options> (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]
                                   [/.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]
                                   [/.tar]
                                   [/.tiff]
                                   [/.typescript]
                                   [/.truetype_font]
                                   [/.microsoft_visio]
                                   [/.wav]
                                   [/.webm_audio]
                                   [/.webm_video]
                                   [/.webp]
                                   [/.woff]
                                   [/.woff2]
                                   [/.xhtml]
                                   [/.microsoft_excel]
                                   [/.microsoft_excel_openxml]
                                   [/.xml]
                                   [/.xul]
                                   [/.zip]

                                   [/.audio_3gpp]
                                   [/.video_3gpp]
                                   [/.audio_3gpp2]
                                   [/.video_3gpp2]
                                   [/.compressed_7z]

                                   [/.form]
                                   [/.multi_part_form]

                                   [/.utf_8])
                  <types> (with_template [<type>]
                            [<type>]
                            
                            <options>)]
  (def .public random
    (Random /.MIME)
    (`` (all random.either
             (,, (with_template [<type>]
                   [(random#in <type>)]
                   
                   <options>))
             )))
  
  (def .public test
    Test
    (<| (_.covering /._)
        (do [! random.monad]
          [expected ..random
           encoding encodingT.random])
        (_.for [/.MIME])
        (all _.and
             (_.for [/.equivalence]
                    (equivalenceS.spec /.equivalence ..random))
             (_.for [/.hash]
                    (hashS.spec /.hash ..random))

             (_.coverage [/.mime /.name]
               (|> expected
                   /.name
                   /.mime
                   (at /.equivalence = expected)))
             (_.coverage [<types>]
               (let [options (list <types>)
                     uniques (set.of_list /.hash options)]
                 (n.= (list.size options)
                      (set.size uniques))))
             (_.coverage [/.text]
               (|> (/.text encoding)
                   /.name
                   (text.contains? (encoding.name encoding))))
             )))
  )