aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/file/extension.lux
blob: 4c3a957ce2e85428cfc987a7911da544c50f3962 (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
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [data
    ["[0]" text]
    [collection
     ["[0]" list]
     ["[0]" set]]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["n" nat]]]
   [meta
    [macro
     ["[0]" template]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(with_expansions [<options> (these [%->d
                                    [/.compressed_7z_archive

                                     /.archive
                                     /.advanced_audio_coding
                                     /.agda_source_code
                                     /.android_application_package
                                     /.assembler_source_code

                                     /.binary
                                     /.bzip2_archive
                                     /.blender_project

                                     /.c_source_code
                                     /.c++_source_code
                                     /.java_class
                                     /.dos_program
                                     /.c#_source_code
                                     /.css
                                     /.comma_separated_values

                                     /.d_source_code
                                     /.dart_source_code]]

                                   [e->j
                                    [/.emacs_lisp_source_code
                                     /.compiled_emacs_lisp_code
                                     /.executable_and_linkable_file
                                     /.electronic_publication
                                     /.erlang_source_code
                                     /.executable_program

                                     /.apophysis_fractal

                                     /.gps_exchange_format
                                     /.gzip_compressed_data

                                     /.http_archive_format
                                     /.c_header
                                     /.html

                                     /.optical_disc_file_system

                                     /.java_archive
                                     /.java_source_code
                                     /.javascript_source_code
                                     /.javascript_object_notation]]

                                   [l->p
                                    [/.llvm_assembly
                                     /.lua_source_code
                                     /.lzip_archive

                                     /.markdown
                                     /.musical_instrument_digital_interface

                                     /.object_code
                                     /.vorbis_audio

                                     /.portable_document_format
                                     /.php_source_code
                                     /.maven_build_configuration
                                     /.postscript_source_code
                                     /.python_source_code]]

                                   [r->z
                                    [/.ruby_source_code

                                     /.scheme_source_code
                                     /.unix_shell_script
                                     /.structured_query_language
                                     /.scalable_vector_graphics
                                     
                                     /.tape_archive
                                     /.temporary_file
                                     /.tab_separated_values

                                     /.yaml

                                     /.zip_archive]])]
  (def all_options
    (list.together (`` (list (,, (with_template [<definition> <by_letter_range>]
                                   [((is (-> Any (List /.Extension))
                                         (function (_ _)
                                           (`` (list (,, (template.spliced <by_letter_range>))))))
                                     123)]
                                   
                                   <options>))))))

  (def unique_options
    (set.of_list text.hash ..all_options))
  
  (def verdict
    (n.= (list.size ..all_options)
         (set.size ..unique_options)))

  (with_template [<definition> <by_letter_range>]
    [(def <definition>
       Test
       (_.coverage <by_letter_range>
         ..verdict))]
    
    <options>)
  
  (def .public test
    Test
    (<| (_.covering /._)
        (do [! random.monad]
          [])
        (_.for [/.Extension])
        (`` (all _.and
                 (,, (with_template [<definition> <by_letter_range>]
                       [<definition>]
                       
                       <options>))
                 (,, (with_template [<original> <aliases>]
                       [(with_expansions [<aliases>' (template.spliced <aliases>)]
                          (`` (_.coverage [(,, (with_template [<extension>]
                                                 [<extension>]
                                                 
                                                 <aliases>'))]
                                (and (,, (with_template [<extension>]
                                           [(same? <original> <extension>)]
                                           
                                           <aliases>'))))))]

                       [/.c_source_code [[/.c]]]
                       [/.c++_source_code [[/.c++]]]
                       [/.comma_separated_values [[/.csv]]]
                       [/.emacs_lisp_source_code [[/.emacs_lisp]]]
                       [/.erlang_source_code [[/.erlang]]]
                       [/.java_archive [[/.jar]]]
                       [/.java_source_code [[/.java]]]
                       [/.javascript_source_code [[/.javascript] [/.js]]]
                       [/.javascript_object_notation [[/.json]]]
                       [/.lua_source_code [[/.lua]]]
                       [/.musical_instrument_digital_interface [[/.midi]]]
                       [/.vorbis_audio [[/.ogg]]]
                       [/.portable_document_format [[/.pdf]]]
                       [/.php_source_code [[/.php]]]
                       [/.python_source_code [[/.python]]]
                       [/.ruby_source_code [[/.ruby]]]
                       [/.scheme_source_code [[/.scheme]]]
                       [/.structured_query_language [[/.sql]]]
                       [/.scalable_vector_graphics [[/.svg]]]
                       [/.tape_archive [[/.tar]]]
                       [/.yaml [[/.yet_another_markup_language] [/.yaml_ain't_markup_language]]]
                       [/.zip_archive [[/.zip]]]
                       ))
                 )))))