From fd8ea1e1b9cae781abe42aeadda2e0ef149994d6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 5 Nov 2022 21:23:20 -0400 Subject: Property-based testing can now log/print successful seeds from run. --- stdlib/source/test/lux.lux | 2 +- stdlib/source/test/lux/test/property.lux | 7 +- stdlib/source/test/lux/world/net.lux | 4 +- stdlib/source/test/lux/world/net/uri/port.lux | 177 ++++++++++++++++++++++++ stdlib/source/test/lux/world/net/uri/scheme.lux | 14 +- 5 files changed, 192 insertions(+), 12 deletions(-) create mode 100644 stdlib/source/test/lux/world/net/uri/port.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index f00cf0abc..d2af0e624 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -1274,6 +1274,6 @@ 100)] (<| io.io _.run! - (_.times times) + (_.times times _.announce_success) ..test )))) diff --git a/stdlib/source/test/lux/test/property.lux b/stdlib/source/test/lux/test/property.lux index dfaaddac5..f5754958a 100644 --- a/stdlib/source/test/lux/test/property.lux +++ b/stdlib/source/test/lux/test/property.lux @@ -62,7 +62,7 @@ /.Test (all /.and (do [! random.monad] - [times_unit_test (/.times 0 (/.test "" true))] + [times_unit_test (/.times 0 /.ignore_success (/.test "" true))] (in (do async.monad [[tally error] times_unit_test] (unit.coverage [/.must_try_test_at_least_once] @@ -73,7 +73,7 @@ [expected (at ! each (|>> (n.% 10) ++) random.nat) .let [counter (is (Atom Nat) (atom.atom 0))] - times_unit_test (<| (/.times expected) + times_unit_test (<| (/.times expected /.ignore_success) (do ! [_ (in []) .let [_ (io.run! (atom.update! ++ counter))]] @@ -85,6 +85,9 @@ (and (n.= expected actual) (n.= 1 (the tally.#successes tally)) (n.= 0 (the tally.#failures tally))))))) + (/.coverage [/.Success_Policy /.ignore_success /.announce_success] + (and (not /.ignore_success) + /.announce_success)) )) (def in_parallel diff --git a/stdlib/source/test/lux/world/net.lux b/stdlib/source/test/lux/world/net.lux index 08c56fa4b..885a918e7 100644 --- a/stdlib/source/test/lux/world/net.lux +++ b/stdlib/source/test/lux/world/net.lux @@ -21,6 +21,7 @@ ["[1][0]" uri ["[1]/[0]" encoding] ["[1]/[0]" scheme] + ["[1]/[0]" port] ["[1]/[0]" path] ["[1]/[0]" query]]]) @@ -32,8 +33,6 @@ (all _.and (_.coverage [/.Host] true) - (_.coverage [/.Port] - true) (_.coverage [/.URL] true) (_.coverage [/.Address] @@ -50,6 +49,7 @@ /uri/encoding.test /uri/scheme.test + /uri/port.test /uri/path.test /uri/query.test ))) diff --git a/stdlib/source/test/lux/world/net/uri/port.lux b/stdlib/source/test/lux/world/net/uri/port.lux new file mode 100644 index 000000000..14ffa5059 --- /dev/null +++ b/stdlib/source/test/lux/world/net/uri/port.lux @@ -0,0 +1,177 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [data + [collection + ["[0]" list] + ["[0]" set]]] + [math + ["[0]" random (.only Random)] + [number + ["[0]" nat]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + []) + (`` (all _.and + (with_expansions [ (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 [] + (let [options (list ) + uniques (set.of_list nat.hash options)] + (nat.= (list.size options) + (set.size uniques))))) + (,, (with_template [ ] + [(_.coverage [] + (same? ))] + + [/.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] + )) + )))) diff --git a/stdlib/source/test/lux/world/net/uri/scheme.lux b/stdlib/source/test/lux/world/net/uri/scheme.lux index c91c49fbf..868f2cddf 100644 --- a/stdlib/source/test/lux/world/net/uri/scheme.lux +++ b/stdlib/source/test/lux/world/net/uri/scheme.lux @@ -134,30 +134,30 @@ [/.ftp /.file_transfer_protocol] [/.http /.hypertext_transfer_protocol] - [/.https /.secure_hypertext_transfer_protocol] + [/.https /.hypertext_transfer_protocol_secure] [/.imap /.internet_message_access_protocol] [/.ipp /.internet_printing_protocol] - [/.ipps /.secure_internet_printing_protocol] + [/.ipps /.internet_printing_protocol_secure] [/.irc /.internet_relay_chat] - [/.ircs /.secure_internet_relay_chat] + [/.ircs /.internet_relay_chat_secure] [/.ldap /.lightweight_directory_access_protocol] - [/.ldaps /.secure_lightweight_directory_access_protocol] + [/.ldaps /.lightweight_directory_access_protocol_secure] [/.pop /.post_office_protocol] [/.sip /.session_initiation_protocol] - [/.sips /.secure_session_initiation_protocol] + [/.sips /.session_initiation_protocol_secure] [/.sms /.short_message_service] [/.snmp /.simple_network_management_protocol] [/.ssh /.secure_shell_protocol] [/.stun /.session_traversal_utilities_for_nat] - [/.stuns /.secure_session_traversal_utilities_for_nat] + [/.stuns /.session_traversal_utilities_for_nat_secure] [/.turn /.traversal_using_relays_around_nat] - [/.turns /.secure_traversal_using_relays_around_nat] + [/.turns /.traversal_using_relays_around_nat_secure] [/.xmpp /.extensible_messaging_and_presence_protocol])) )))) -- cgit v1.2.3