aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/net/http/status.lux
blob: 4ba7605375c10cde26b278197b2aa35c90e03700 (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
(.using
 [library
  [lux (.except all)
   ["_" test (.only Test)]
   [data
    [collection
     ["[0]" list]
     ["[0]" set (.only Set)]]]
   [macro
    ["[0]" template]]
   [math
    [number
     ["n" nat]]]]]
 [\\library
  ["[0]" / (.only)
   ["/[1]" //]]])

(with_expansions [<categories> (these [informational
                                       [/.continue
                                        /.switching_protocols
                                        /.processing
                                        /.early_hints]]
                                      [success
                                       [/.ok
                                        /.created
                                        /.accepted
                                        /.non_authoritative_information
                                        /.no_content
                                        /.reset_content
                                        /.partial_content
                                        /.multi_status
                                        /.already_reported
                                        /.im_used]]
                                      [redirection
                                       [/.multiple_choices
                                        /.moved_permanently
                                        /.found
                                        /.see_other
                                        /.not_modified
                                        /.use_proxy
                                        /.switch_proxy
                                        /.temporary_redirect
                                        /.permanent_redirect]]
                                      [client
                                       [/.bad_request
                                        /.unauthorized
                                        /.payment_required
                                        /.forbidden
                                        /.not_found
                                        /.method_not_allowed
                                        /.not_acceptable
                                        /.proxy_authentication_required
                                        /.request_timeout
                                        /.conflict
                                        /.gone
                                        /.length_required
                                        /.precondition_failed
                                        /.payload_too_large
                                        /.uri_too_long
                                        /.unsupported_media_type
                                        /.range_not_satisfiable
                                        /.expectation_failed
                                        /.im_a_teapot
                                        /.misdirected_request
                                        /.unprocessable_entity
                                        /.locked
                                        /.failed_dependency
                                        /.upgrade_required
                                        /.precondition_required
                                        /.too_many_requests
                                        /.request_header_fields_too_large
                                        /.unavailable_for_legal_reasons]]
                                      [server
                                       [/.internal_server_error
                                        /.not_implemented
                                        /.bad_gateway
                                        /.service_unavailable
                                        /.gateway_timeout
                                        /.http_version_not_supported
                                        /.variant_also_negotiates
                                        /.insufficient_storage
                                        /.loop_detected
                                        /.not_extended
                                        /.network_authentication_required]])]
  (def all
    (List //.Status)
    (list.together (`` (list (~~ (with_template [<category> <status+>]
                                   [((is (-> Any (List //.Status))
                                         (function (_ _)
                                           (`` (list (~~ (template.spliced <status+>))))))
                                     123)]
                                   
                                   <categories>))))))
  
  (def unique
    (Set //.Status)
    (set.of_list n.hash ..all))

  (def verdict
    (n.= (list.size ..all)
         (set.size ..unique)))

  (with_template [<category> <status+>]
    [(def <category>
       Test
       (_.coverage <status+>
         ..verdict))]
    
    <categories>)

  (def .public test
    Test
    (<| (_.covering /._)
        (`` (.all _.and
                  (~~ (with_template [<category> <status+>]
                        [<category>]
                        
                        <categories>))
                  ))))
  )