diff options
author | Eduardo Julian | 2022-11-06 20:52:21 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-11-06 20:52:21 -0400 |
commit | ae4c0a4746d59b552ebeba166a43ce756dd265af (patch) | |
tree | 8548fb3e4a77bd986d459a639ee31cf2455fe20e /stdlib/source/test | |
parent | fd8ea1e1b9cae781abe42aeadda2e0ef149994d6 (diff) |
More efficient code-generation for text composition.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/control.lux | 2 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/text.lux | 2 | ||||
-rw-r--r-- | stdlib/source/test/lux/documentation.lux | 6 | ||||
-rw-r--r-- | stdlib/source/test/lux/documentation/remember.lux (renamed from stdlib/source/test/lux/control/remember.lux) | 0 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/net.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/net/http/request.lux | 226 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/net/mime.lux | 3 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/net/uri/port.lux | 327 |
8 files changed, 408 insertions, 162 deletions
diff --git a/stdlib/source/test/lux/control.lux b/stdlib/source/test/lux/control.lux index 67903a051..1643a541d 100644 --- a/stdlib/source/test/lux/control.lux +++ b/stdlib/source/test/lux/control.lux @@ -30,7 +30,6 @@ ["[1][0]" pipe] ["[1][0]" reader] ["[1][0]" region] - ["[1][0]" remember] [security ["[1][0]" policy] ["[1][0]" capability]] @@ -80,7 +79,6 @@ /pipe.test /reader.test /region.test - /remember.test ..security /state.test /thread.test diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index d192289cf..1ee5a2bf0 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -166,7 +166,7 @@ right (random.unicode 5)] (_.coverage [\\format.format] (/#= (\\format.format left mid right) - (all .text_composite# left mid right)))) + (.text_composite# left mid right)))) ..codec (,, (with_template [<format> <alias> <random>] [(do random.monad diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux index 6308232c7..83fe198e3 100644 --- a/stdlib/source/test/lux/documentation.lux +++ b/stdlib/source/test/lux/documentation.lux @@ -20,7 +20,9 @@ [test ["_" property (.only Test)]]]] [\\library - ["[0]" /]]) + ["[0]" /]] + ["[0]" / + ["[1][0]" remember]]) (def macro_error (syntax (_ [macro <code>.any]) @@ -81,4 +83,6 @@ [(/.definition g!default (,, (template.text ['definition_description'])))] ))))) + + /remember.test ))))) diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/documentation/remember.lux index 963b3fbc1..963b3fbc1 100644 --- a/stdlib/source/test/lux/control/remember.lux +++ b/stdlib/source/test/lux/documentation/remember.lux diff --git a/stdlib/source/test/lux/world/net.lux b/stdlib/source/test/lux/world/net.lux index 885a918e7..ad3a3fa1e 100644 --- a/stdlib/source/test/lux/world/net.lux +++ b/stdlib/source/test/lux/world/net.lux @@ -17,7 +17,8 @@ ["[1]/[0]" header] ["[1]/[0]" status] ["[1]/[0]" version] - ["[1]/[0]" response]] + ["[1]/[0]" response] + ["[1]/[0]" request]] ["[1][0]" uri ["[1]/[0]" encoding] ["[1]/[0]" scheme] @@ -46,6 +47,7 @@ /http/status.test /http/version.test /http/response.test + /http/request.test /uri/encoding.test /uri/scheme.test diff --git a/stdlib/source/test/lux/world/net/http/request.lux b/stdlib/source/test/lux/world/net/http/request.lux new file mode 100644 index 000000000..0d117920f --- /dev/null +++ b/stdlib/source/test/lux/world/net/http/request.lux @@ -0,0 +1,226 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [control + ["|" pipe] + ["[0]" try]] + [data + ["[0]" identity (.only Identity)] + ["[0]" binary (.use "[1]#[0]" equivalence)] + [text + [encoding + ["[0]" utf8 (.use "[1]#[0]" codec)]]] + [format + ["[0]" json (.use "[1]#[0]" codec) + ["[1]T" \\test]]]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" / (.only) + ["/[1]" // (.only) + ["[0]" header] + [// + ["[0]" mime (.use "[1]#[0]" equivalence)] + [uri + ["[0]" scheme (.use "[1]#[0]" equivalence)] + ["[0]" query (.use "[1]#[0]" codec) + ["[1]T" \\test]]]]]]]) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [expected_text (random.upper_cased 3) + expected_json jsonT.random + expected_form (queryT.random 2) + expected_uri (random.upper_cased 4) + expected_content_length random.nat]) + (_.for [/.Request + /.#identification /.#message /.#protocol /.#resource]) + (`` (all _.and + (_.coverage [/.utf8 /.text] + (and (same? /.utf8 /.text) + (let [it (/.utf8 identity.monad expected_text)] + (and (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.utf_8 actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded expected_text) + actual) + + {try.#Failure error} + false) + )))) + (_.coverage [/.json] + (let [it (/.json identity.monad expected_json)] + (and (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.json actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded (json#encoded expected_json)) + actual) + + {try.#Failure error} + false) + ))) + (_.coverage [/.form] + (let [it (/.form identity.monad expected_form)] + (and (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.form actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded (query#encoded expected_form)) + actual) + + {try.#Failure error} + false) + ))) + (,, (with_template [<request> <scheme>] + [(_.coverage [<request>] + (let [it (is (/.Request Identity) + (<request> (/.utf8 identity.monad expected_text)))] + (and (|> it + (the [/.#protocol //.#scheme]) + (scheme#= <scheme>)) + (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.utf_8 actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded expected_text) + actual) + + {try.#Failure error} + false) + )))] + + [/.http scheme.http] + [/.https scheme.https] + )) + (,, (with_template [<request> <method>] + [(_.coverage [<request>] + (let [it (is (/.Request Identity) + (<request> (/.utf8 identity.monad expected_text)))] + (and (|> it + (the [/.#resource //.#method]) + (|.when + {<method>} + true + + _ + false)) + (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.utf_8 actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded expected_text) + actual) + + {try.#Failure error} + false) + )))] + + [/.post //.#Post] + [/.get //.#Get] + [/.put //.#Put] + [/.patch //.#Patch] + [/.delete //.#Delete] + [/.head //.#Head] + [/.connect //.#Connect] + [/.options //.#Options] + [/.trace //.#Trace] + )) + (_.coverage [/.uri] + (let [it (is (/.Request Identity) + (/.uri expected_uri (/.utf8 identity.monad expected_text)))] + (and (|> it + (the [/.#resource //.#uri]) + (same? expected_uri)) + (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.utf_8 actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded expected_text) + actual) + + {try.#Failure error} + false) + ))) + (_.coverage [/.with_header] + (let [it (is (/.Request Identity) + (|> (/.utf8 identity.monad expected_text) + (/.with_header header.content_length expected_content_length)))] + (and (|> it + (the [/.#message //.#headers]) + (header.one header.content_length) + (|.when + {try.#Success actual} + (n.= expected_content_length actual) + + {try.#Failure error} + false)) + (|> it + (the [/.#message //.#headers]) + (header.one header.content_type) + (|.when + {try.#Success actual} + (mime#= mime.utf_8 actual) + + {try.#Failure error} + false)) + (when ((the [/.#message //.#body] it) {.#None}) + {try.#Success [_ actual]} + (binary#= (utf8#encoded expected_text) + actual) + + {try.#Failure error} + false) + ))) + )))) diff --git a/stdlib/source/test/lux/world/net/mime.lux b/stdlib/source/test/lux/world/net/mime.lux index 8c5c84033..c1116ad5a 100644 --- a/stdlib/source/test/lux/world/net/mime.lux +++ b/stdlib/source/test/lux/world/net/mime.lux @@ -89,6 +89,9 @@ [/.video_3gpp2] [/.compressed_7z] + [/.form] + [/.multi_part_form] + [/.utf_8]) <types> (with_template [<type>] [<type>] diff --git a/stdlib/source/test/lux/world/net/uri/port.lux b/stdlib/source/test/lux/world/net/uri/port.lux index 14ffa5059..d91dc1d5d 100644 --- a/stdlib/source/test/lux/world/net/uri/port.lux +++ b/stdlib/source/test/lux/world/net/uri/port.lux @@ -8,7 +8,7 @@ ["[0]" list] ["[0]" set]]] [math - ["[0]" random (.only Random)] + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] [number ["[0]" nat]]] [test @@ -16,162 +16,175 @@ [\\library ["[0]" /]]) -(def .public test - Test - (<| (_.covering /._) - (do [! random.monad] - []) - (`` (all _.and - (with_expansions [<options> (these /.echo_protocol - /.discard_protocol - /.daytime_protocol - /.quote_of_the_day - /.message_send_protocol - /.character_generator_protocol - /.file_transfer_protocol_data_transfer - /.file_transfer_protocol_control - /.telnet - /.simple_mail_transfer_protocol - /.time_protocol - /.host_name_server_protocol - /.whois - /.domain_name_system - /.gopher - /.finger - /.hypertext_transfer_protocol - /.kerberos - - /.digital_imaging_and_communications_in_medicine - /.remote_user_telnet_service - /.post_office_protocol_2 - /.post_office_protocol_3 - /.open_network_computing_remote_procedure_call - /.simple_file_transfer_protocol - /.network_news_transfer_protocol - /.network_time_protocol - /.internet_message_access_protocol - /.simple_gateway_monitoring_protocol - /.structured_query_language - /.simple_network_management_protocol - /.simple_network_management_protocol_trap - /.secure_neighbor_discovery - /.x_display_manager_control_protocol - /.border_gateway_protocol - /.internet_relay_chat - /.snmp_unix_multiplexer - - /.border_gateway_multicast_protocol - - /.precision_time_protocol_event_messages - /.precision_time_protocol_general_messages - /.lightweight_directory_access_protocol - - /.uninterruptible_power_supply - /.service_location_protocol - /.hypertext_transfer_protocol_secure - /.simple_network_paging_protocol - /.kerberos_change/set_password - - /.remote_procedure_call - /.real_time_streaming_protocol - /.dynamic_host_configuration_protocol/6_client - /.dynamic_host_configuration_protocol/6_server - /.network_news_transfer_protocol_secure - - /.internet_printing_protocol - /.lightweight_directory_access_protocol_secure - /.multicast_source_discovery_protocol - /.label_distribution_protocol - /.application_configuration_access_protocol - /.optimized_link_state_routing_protocol - - /.extensible_provisioning_protocol - /.link_management_protocol - /.secure_internet_live_conferencing_protocol - /.kerberos_administration - - /.certificate_management_protocol - /.network_configuration_protocol/ssh - /.network_configuration_protocol/beep - /.network_configuration_protocol/soap/https - /.network_configuration_protocol/soap/beep - - /.file_transfer_protocol_secure_data_transfer - /.file_transfer_protocol_secure_control - /.telnet/tls - /.internet_message_access_protocol_secure - /.post_office_protocol_3_secure)] - (_.coverage [<options>] +(with_expansions [<options> (these [/.echo_protocol] + [/.discard_protocol] + [/.daytime_protocol] + [/.quote_of_the_day] + [/.message_send_protocol] + [/.character_generator_protocol] + [/.file_transfer_protocol_data_transfer] + [/.file_transfer_protocol_control] + [/.telnet] + [/.simple_mail_transfer_protocol] + [/.time_protocol] + [/.host_name_server_protocol] + [/.whois] + [/.domain_name_system] + [/.gopher] + [/.finger] + [/.hypertext_transfer_protocol] + [/.kerberos] + + [/.digital_imaging_and_communications_in_medicine] + [/.remote_user_telnet_service] + [/.post_office_protocol_2] + [/.post_office_protocol_3] + [/.open_network_computing_remote_procedure_call] + [/.simple_file_transfer_protocol] + [/.network_news_transfer_protocol] + [/.network_time_protocol] + [/.internet_message_access_protocol] + [/.simple_gateway_monitoring_protocol] + [/.structured_query_language] + [/.simple_network_management_protocol] + [/.simple_network_management_protocol_trap] + [/.secure_neighbor_discovery] + [/.x_display_manager_control_protocol] + [/.border_gateway_protocol] + [/.internet_relay_chat] + [/.snmp_unix_multiplexer] + + [/.border_gateway_multicast_protocol] + + [/.precision_time_protocol_event_messages] + [/.precision_time_protocol_general_messages] + [/.lightweight_directory_access_protocol] + + [/.uninterruptible_power_supply] + [/.service_location_protocol] + [/.hypertext_transfer_protocol_secure] + [/.simple_network_paging_protocol] + [/.kerberos_change/set_password] + + [/.remote_procedure_call] + [/.real_time_streaming_protocol] + [/.dynamic_host_configuration_protocol/6_client] + [/.dynamic_host_configuration_protocol/6_server] + [/.network_news_transfer_protocol_secure] + + [/.internet_printing_protocol] + [/.lightweight_directory_access_protocol_secure] + [/.multicast_source_discovery_protocol] + [/.label_distribution_protocol] + [/.application_configuration_access_protocol] + [/.optimized_link_state_routing_protocol] + + [/.extensible_provisioning_protocol] + [/.link_management_protocol] + [/.secure_internet_live_conferencing_protocol] + [/.kerberos_administration] + + [/.certificate_management_protocol] + [/.network_configuration_protocol/ssh] + [/.network_configuration_protocol/beep] + [/.network_configuration_protocol/soap/https] + [/.network_configuration_protocol/soap/beep] + + [/.file_transfer_protocol_secure_data_transfer] + [/.file_transfer_protocol_secure_control] + [/.telnet/tls] + [/.internet_message_access_protocol_secure] + [/.post_office_protocol_3_secure])] + (def .public random + (Random /.Port) + (`` (all random.either + (,, (with_template [<port>] + [(random#in <port>)] + + <options> + ))))) + + (def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + []) + (`` (all _.and + (_.coverage [(,, (with_template [<port>] + [<port>] + + <options> + ))] (let [options (list <options>) uniques (set.of_list nat.hash options)] (nat.= (list.size options) - (set.size uniques))))) - (,, (with_template [<long> <short>] - [(_.coverage [<short>] - (same? <long> <short>))] - - [/.file_transfer_protocol_data_transfer /.ftp_data_transfer] - [/.file_transfer_protocol_control /.ftp_control] - [/.simple_mail_transfer_protocol /.smtp] - [/.domain_name_system /.dns] - [/.hypertext_transfer_protocol /.http] - - [/.digital_imaging_and_communications_in_medicine /.dicom] - [/.remote_user_telnet_service /.rtelnet] - [/.post_office_protocol_2 /.pop2] - [/.post_office_protocol_3 /.pop3] - [/.open_network_computing_remote_procedure_call /.onc_rpc] - [/.simple_file_transfer_protocol /.simple_ftp] - [/.network_news_transfer_protocol /.nntp] - [/.network_time_protocol /.ntp] - [/.internet_message_access_protocol /.imap] - [/.simple_gateway_monitoring_protocol /.sgmp] - [/.structured_query_language /.sql] - [/.simple_network_management_protocol /.snmp] - [/.simple_network_management_protocol_trap /.snmp_trap] - [/.secure_neighbor_discovery /.send] - [/.x_display_manager_control_protocol /.xdmcp] - [/.border_gateway_protocol /.bgp] - [/.internet_relay_chat /.irc] - [/.snmp_unix_multiplexer /.smux] - - [/.border_gateway_multicast_protocol /.bgmp] - - [/.precision_time_protocol_event_messages /.ptp_event_messages] - [/.precision_time_protocol_general_messages /.ptp_general_messages] - [/.lightweight_directory_access_protocol /.ldap] - - [/.uninterruptible_power_supply /.ups] - [/.service_location_protocol /.slp] - [/.hypertext_transfer_protocol_secure /.https] - [/.simple_network_paging_protocol /.snpp] - - [/.remote_procedure_call /.rpc] - [/.real_time_streaming_protocol /.rtsp] - [/.dynamic_host_configuration_protocol/6_client /.dhcp/6_client] - [/.dynamic_host_configuration_protocol/6_server /.dhcp/6_server] - [/.network_news_transfer_protocol_secure /.nntps] - - [/.internet_printing_protocol /.ipp] - [/.lightweight_directory_access_protocol_secure /.ldaps] - [/.multicast_source_discovery_protocol /.msdp] - [/.label_distribution_protocol /.ldp] - [/.application_configuration_access_protocol /.acap] - [/.optimized_link_state_routing_protocol /.olsr] - - [/.extensible_provisioning_protocol /.epp] - [/.link_management_protocol /.lmp] - [/.secure_internet_live_conferencing_protocol /.silc] - - [/.certificate_management_protocol /.cmp] - [/.network_configuration_protocol/ssh /.netconf/ssh] - [/.network_configuration_protocol/beep /.netconf/beep] - [/.network_configuration_protocol/soap/https /.netconf/soap/https] - [/.network_configuration_protocol/soap/beep /.netconf/soap/beep] - - [/.file_transfer_protocol_secure_data_transfer /.ftps_data_transfer] - [/.file_transfer_protocol_secure_control /.ftps_control] - [/.internet_message_access_protocol_secure /.imaps] - [/.post_office_protocol_3_secure /.pop3s] - )) - )))) + (set.size uniques)))) + (,, (with_template [<long> <short>] + [(_.coverage [<short>] + (same? <long> <short>))] + + [/.file_transfer_protocol_data_transfer /.ftp_data_transfer] + [/.file_transfer_protocol_control /.ftp_control] + [/.simple_mail_transfer_protocol /.smtp] + [/.domain_name_system /.dns] + [/.hypertext_transfer_protocol /.http] + + [/.digital_imaging_and_communications_in_medicine /.dicom] + [/.remote_user_telnet_service /.rtelnet] + [/.post_office_protocol_2 /.pop2] + [/.post_office_protocol_3 /.pop3] + [/.open_network_computing_remote_procedure_call /.onc_rpc] + [/.simple_file_transfer_protocol /.simple_ftp] + [/.network_news_transfer_protocol /.nntp] + [/.network_time_protocol /.ntp] + [/.internet_message_access_protocol /.imap] + [/.simple_gateway_monitoring_protocol /.sgmp] + [/.structured_query_language /.sql] + [/.simple_network_management_protocol /.snmp] + [/.simple_network_management_protocol_trap /.snmp_trap] + [/.secure_neighbor_discovery /.send] + [/.x_display_manager_control_protocol /.xdmcp] + [/.border_gateway_protocol /.bgp] + [/.internet_relay_chat /.irc] + [/.snmp_unix_multiplexer /.smux] + + [/.border_gateway_multicast_protocol /.bgmp] + + [/.precision_time_protocol_event_messages /.ptp_event_messages] + [/.precision_time_protocol_general_messages /.ptp_general_messages] + [/.lightweight_directory_access_protocol /.ldap] + + [/.uninterruptible_power_supply /.ups] + [/.service_location_protocol /.slp] + [/.hypertext_transfer_protocol_secure /.https] + [/.simple_network_paging_protocol /.snpp] + + [/.remote_procedure_call /.rpc] + [/.real_time_streaming_protocol /.rtsp] + [/.dynamic_host_configuration_protocol/6_client /.dhcp/6_client] + [/.dynamic_host_configuration_protocol/6_server /.dhcp/6_server] + [/.network_news_transfer_protocol_secure /.nntps] + + [/.internet_printing_protocol /.ipp] + [/.lightweight_directory_access_protocol_secure /.ldaps] + [/.multicast_source_discovery_protocol /.msdp] + [/.label_distribution_protocol /.ldp] + [/.application_configuration_access_protocol /.acap] + [/.optimized_link_state_routing_protocol /.olsr] + + [/.extensible_provisioning_protocol /.epp] + [/.link_management_protocol /.lmp] + [/.secure_internet_live_conferencing_protocol /.silc] + + [/.certificate_management_protocol /.cmp] + [/.network_configuration_protocol/ssh /.netconf/ssh] + [/.network_configuration_protocol/beep /.netconf/beep] + [/.network_configuration_protocol/soap/https /.netconf/soap/https] + [/.network_configuration_protocol/soap/beep /.netconf/soap/beep] + + [/.file_transfer_protocol_secure_data_transfer /.ftps_data_transfer] + [/.file_transfer_protocol_secure_control /.ftps_control] + [/.internet_message_access_protocol_secure /.imaps] + [/.post_office_protocol_3_secure /.pop3s] + )) + ))))) |