From 523074289af8d9b473ed89e60fa586498de75aff Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 8 Jul 2022 02:09:34 -0400 Subject: Moved "lux/locale" to "lux/world/locale". --- stdlib/source/test/lux.lux | 2 - stdlib/source/test/lux/locale.lux | 98 ------- stdlib/source/test/lux/locale/language.lux | 301 ---------------------- stdlib/source/test/lux/locale/territory.lux | 227 ---------------- stdlib/source/test/lux/world.lux | 4 +- stdlib/source/test/lux/world/locale.lux | 98 +++++++ stdlib/source/test/lux/world/locale/language.lux | 301 ++++++++++++++++++++++ stdlib/source/test/lux/world/locale/territory.lux | 227 ++++++++++++++++ 8 files changed, 629 insertions(+), 629 deletions(-) delete mode 100644 stdlib/source/test/lux/locale.lux delete mode 100644 stdlib/source/test/lux/locale/language.lux delete mode 100644 stdlib/source/test/lux/locale/territory.lux create mode 100644 stdlib/source/test/lux/world/locale.lux create mode 100644 stdlib/source/test/lux/world/locale/language.lux create mode 100644 stdlib/source/test/lux/world/locale/territory.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 7212f5fb4..23d89ee6e 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -47,7 +47,6 @@ ["[1][0]" debug] ["[1][0]" documentation] - ["[1][0]" locale] ["[1][0]" math] ["[1][0]" meta] @@ -1204,7 +1203,6 @@ /debug.test /documentation.test - /locale.test /math.test /meta.test diff --git a/stdlib/source/test/lux/locale.lux b/stdlib/source/test/lux/locale.lux deleted file mode 100644 index b7c99d34a..000000000 --- a/stdlib/source/test/lux/locale.lux +++ /dev/null @@ -1,98 +0,0 @@ -(.require - [library - [lux (.except) - ["_" test (.only Test)] - [abstract - [monad (.only do)] - [\\specification - ["$[0]" equivalence] - ["$[0]" hash]]] - [math - ["[0]" random (.only Random) (.use "[1]#[0]" monad)]] - [data - ["[0]" text (.use "[1]#[0]" equivalence) - ["[0]" encoding (.only Encoding)]] - [collection - ["[0]" list]]]]] - ["[0]" / - ["[1][0]" language] - ["[1][0]" territory]] - [\\library - ["[0]" / (.only) - ["[0]" language (.only Language)] - ["[0]" territory (.only Territory)]]]) - -(def random_language - (Random Language) - (random.either (random#in language.afar) - (random#in language.zaza))) - -(def random_territory - (Random Territory) - (random.either (random#in territory.afghanistan) - (random#in territory.zimbabwe))) - -(def random_encoding - (Random Encoding) - (random.either (random#in encoding.ascii) - (random#in encoding.koi8_u))) - -(def random_locale - (Random /.Locale) - (do random.monad - [language ..random_language - territory ..random_territory - encoding ..random_encoding] - (in (/.locale language {.#Some territory} {.#Some encoding})))) - -(def .public test - Test - (<| (_.covering /._) - (_.for [/.Locale]) - (all _.and - (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..random_locale)) - (_.for [/.hash] - (do [! random.monad] - [fixed_language ..random_language - fixed_territory ..random_territory - fixed_encoding ..random_encoding] - (all _.and - (|> ..random_language - (at ! each (function (_ language) - (/.locale language {.#Some fixed_territory} {.#Some fixed_encoding}))) - ($hash.spec /.hash)) - (|> ..random_territory - (at ! each (function (_ territory) - (/.locale fixed_language {.#Some territory} {.#Some fixed_encoding}))) - ($hash.spec /.hash)) - (|> ..random_encoding - (at ! each (function (_ encoding) - (/.locale fixed_language {.#Some fixed_territory} {.#Some encoding}))) - ($hash.spec /.hash)) - ))) - - (do random.monad - [language ..random_language - territory ..random_territory - encoding ..random_encoding - .let [l_locale (/.locale language {.#None} {.#None}) - lt_locale (/.locale language {.#Some territory} {.#None}) - le_locale (/.locale language {.#None} {.#Some encoding}) - lte_locale (/.locale language {.#Some territory} {.#Some encoding})] - .let [language_check (and (text#= (language.code language) - (/.code l_locale)) - (list.every? (|>> /.code (text.starts_with? (language.code language))) - (list lt_locale le_locale lte_locale))) - territory_check (list.every? (|>> /.code (text.contains? (territory.long_code territory))) - (list lt_locale lte_locale)) - encoding_check (list.every? (|>> /.code (text.ends_with? (encoding.name encoding))) - (list le_locale lte_locale))]] - (_.coverage [/.locale /.code] - (and language_check - territory_check - encoding_check))) - - /language.test - /territory.test - ))) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux deleted file mode 100644 index edabb90d2..000000000 --- a/stdlib/source/test/lux/locale/language.lux +++ /dev/null @@ -1,301 +0,0 @@ -(.require - [library - [lux (.except) - ["_" test (.only Test)] - [abstract - [monad (.only do)] - [hash (.only Hash)] - [\\specification - ["$[0]" hash]]] - [control - ["[0]" maybe]] - [data - ["[0]" text] - [collection - ["[0]" set (.only Set)] - ["[0]" list (.use "[1]#[0]" functor mix)]]] - [math - ["[0]" random (.only Random)] - [number - ["n" nat]]] - [meta - [macro - ["[0]" template]]]]] - [\\library - ["[0]" /]]) - -(type Bundle - (Record - [#amount Nat - #names (Set Text) - #codes (Set Text) - #languages (Set /.Language) - #test Test])) - -(with_template [ ] - [(def - Bundle - (let [amount (template.amount ) - languages (is (List /.Language) - (`` (list (,, (template.spliced )))))] - [#amount amount - #names (|> languages (list#each /.name) (set.of_list text.hash)) - #codes (|> languages (list#each /.code) (set.of_list text.hash)) - #languages (set.of_list /.hash languages) - #test (_.coverage - true)]))] - - [languages/a [/.afar /.abkhazian /.achinese /.acoli /.adangme - /.adyghe /.afro_asiatic /.afrihili /.afrikaans /.ainu - /.akan /.akkadian /.aleut /.algonquian /.southern_altai - /.amharic /.old_english /.angika /.apache /.arabic - /.official_aramaic /.aragonese /.mapudungun /.arapaho /.artificial - /.arawak /.assamese /.asturian /.athapascan /.australian - /.avaric /.avestan /.awadhi /.aymara /.azerbaijani]] - [languages/b [/.banda /.bamileke /.bashkir /.baluchi /.bambara - /.balinese /.basa /.baltic /.beja /.belarusian - /.bemba /.bengali /.berber /.bhojpuri /.bihari - /.bikol /.bini /.bislama /.siksika /.bantu - /.tibetan /.bosnian /.braj /.breton /.batak - /.buriat /.buginese /.bulgarian /.blin]] - [languages/c [/.caddo /.central_american_indian /.galibi_carib /.catalan /.caucasian - /.cebuano /.celtic /.czech /.chamorro /.chibcha - /.chechen /.chagatai /.chuukese /.mari /.chinook - /.choctaw /.chipewyan /.cherokee /.church_slavic /.chuvash - /.cheyenne /.chamic /.montenegrin /.coptic /.cornish - /.corsican /.creoles_and_pidgins/english /.creoles_and_pidgins/french /.creoles_and_pidgins/portuguese /.cree - /.crimean /.creoles_and_pidgins /.kashubian /.cushitic /.welsh]] - [languages/d [/.dakota /.danish /.dargwa /.land_dayak /.delaware - /.slavey /.dogrib /.dinka /.dhivehi /.dogri - /.dravidian /.lower_sorbian /.duala /.middle_dutch /.dyula - /.dzongkha]] - [languages/e [/.efik /.egyptian /.ekajuk /.greek /.elamite - /.english /.middle_english /.esperanto /.estonian /.basque - /.ewe /.ewondo]] - [languages/f [/.fang /.faroese /.persian /.fanti /.fijian - /.filipino /.finnish /.finno_ugrian /.fon /.french - /.middle_french /.old_french /.northern_frisian /.eastern_frisian /.western_frisian - /.fulah /.friulian]] - [languages/g [/.ga /.gayo /.gbaya /.germanic /.german - /.geez /.gilbertese /.gaelic /.irish /.galician - /.manx /.middle_high_german /.old_high_german /.gondi /.gorontalo - /.gothic /.grebo /.ancient_greek /.guarani /.swiss_german - /.gujarati /.gwich'in]] - [languages/h [/.haida /.haitian /.hausa /.hawaiian /.hebrew - /.herero /.hiligaynon /.himachali /.hindi /.hittite - /.hmong /.hiri_motu /.croatian /.upper_sorbian /.hungarian - /.hupa /.armenian]] - [languages/i [/.iban /.igbo /.ido /.sichuan_yi /.ijo - /.inuktitut /.interlingue /.iloko /.interlingua /.indic - /.indonesian /.indo_european /.ingush /.inupiaq /.iranian - /.iroquoian /.icelandic /.italian]] - [languages/j [/.javanese /.lojban /.japanese /.judeo_persian /.judeo_arabic]] - [languages/k [/.kara_kalpak /.kabyle /.kachin /.kalaallisut /.kamba - /.kannada /.karen /.kashmiri /.georgian /.kanuri - /.kawi /.kazakh /.kabardian /.khasi /.khoisan - /.central_khmer /.khotanese /.gikuyu /.kinyarwanda /.kyrgyz - /.kimbundu /.konkani /.komi /.kongo /.korean - /.kosraean /.kpelle /.karachay_balkar /.karelian /.kru - /.kurukh /.kwanyama /.kumyk /.kurdish /.kutenai]] - [languages/l [/.ladino /.lahnda /.lamba /.lao /.latin - /.latvian /.lezghian /.limburgan /.lingala /.lithuanian - /.mongo /.lozi /.luxembourgish /.luba_lulua /.luba_katanga - /.ganda /.luiseno /.lunda /.luo /.lushai]] - [languages/m [/.madurese /.magahi /.marshallese /.maithili /.makasar - /.malayalam /.mandingo /.austronesian /.marathi /.masai - /.moksha /.mandar /.mende /.middle_irish /.mi'kmaq - /.minangkabau /.macedonian /.mon_khmer /.malagasy /.maltese - /.manchu /.manipuri /.manobo /.mohawk /.mongolian - /.mossi /.maori /.malay /.munda /.creek - /.mirandese /.marwari /.burmese /.mayan /.erzya]] - [languages/n [/.nahuatl /.north_american_indian /.neapolitan /.nauru /.navajo - /.south_ndebele /.north_ndebele /.ndonga /.low_german /.nepali - /.newari /.nias /.niger_kordofanian /.niuean /.dutch - /.nynorsk /.bokmal /.nogai /.old_norse /.norwegian - /.n'ko /.northern_sotho /.nubian /.old_newari /.nyanja - /.nyamwezi /.nyankole /.nyoro /.nzima]] - [languages/o [/.occitan /.ojibwa /.oriya /.oromo /.osage - /.ossetic /.ottoman_turkish /.otomian]] - [languages/p [/.papuan /.pangasinan /.pahlavi /.pampanga /.punjabi - /.papiamento /.palauan /.old_persian /.philippine /.phoenician - /.pali /.polish /.pohnpeian /.portuguese /.prakrit - /.old_provencal /.pashto]] - [languages/q [/.quechua]] - [languages/r [/.rajasthani /.rapanui /.rarotongan /.romance /.romansh - /.romany /.romanian /.rundi /.aromanian /.russian]] - [languages/s0 [/.sandawe /.sango /.yakut /.south_american_indian /.salishan - /.samaritan_aramaic /.sanskrit /.sasak /.santali /.sicilian - /.scots /.selkup /.semitic /.old_irish /.sign - /.shan /.sidamo /.sinhalese /.siouan /.sino_tibetan - /.slavic /.slovak /.slovenian /.southern_sami /.northern_sami - /.sami /.lule /.inari /.samoan /.skolt_sami]] - [languages/s1 [/.shona /.sindhi /.soninke /.sogdian /.somali - /.songhai /.southern_sotho /.spanish /.albanian /.sardinian - /.sranan_tongo /.serbian /.serer /.nilo_saharan /.swati - /.sukuma /.sundanese /.susu /.sumerian /.swahili - /.swedish /.classical_syriac /.syriac]] - [languages/t [/.tahitian /.tai /.tamil /.tatar /.telugu - /.timne /.tereno /.tetum /.tajik /.tagalog - /.thai /.tigre /.tigrinya /.tiv /.tokelau - /.klingon /.tlingit /.tamashek /.tonga /.tongan - /.tok_pisin /.tsimshian /.tswana /.tsonga /.turkmen - /.tumbuka /.tupi /.turkish /.altaic /.tuvalu - /.twi /.tuvinian]] - [languages/u [/.udmurt /.ugaritic /.uyghur /.ukrainian /.umbundu - /.urdu /.uzbek]] - [languages/v [/.vai /.venda /.vietnamese /.volapük /.votic]] - [languages/w [/.wakashan /.walamo /.waray /.washo /.sorbian - /.walloon /.wolof]] - [languages/x [/.kalmyk /.xhosa]] - [languages/y [/.yao /.yapese /.yiddish /.yoruba /.yupik]] - [languages/z [/.zapotec /.blissymbols /.zenaga /.standard_moroccan_tamazight /.zhuang - /.chinese /.zande /.zulu /.zuni /.zaza]] - [languages/etc [/.uncoded /.multiple /.undetermined /.not_applicable]] - ) - -(def languages - (List Bundle) - (list ..languages/a - ..languages/b - ..languages/c - ..languages/d - ..languages/e - ..languages/f - ..languages/g - ..languages/h - ..languages/i - ..languages/j - ..languages/k - ..languages/l - ..languages/m - ..languages/n - ..languages/o - ..languages/p - ..languages/q - ..languages/r - ..languages/s0 - ..languages/s1 - ..languages/t - ..languages/u - ..languages/v - ..languages/w - ..languages/x - ..languages/y - ..languages/z - ..languages/etc - )) - -(def (aggregate lens hash territories) - (All (_ a) (-> (-> Bundle (Set a)) - (Hash a) - (List Bundle) - [Nat (Set a)])) - (list#mix (function (_ bundle [amount set]) - [(n.+ amount (the #amount bundle)) - (set.union set (lens bundle))]) - [0 (set.empty hash)] - territories)) - -(def languages_test - Test - (|> ..languages - list.reversed - (list#each (the #test)) - (list#mix _.and - (`` (all _.and - (,, (with_template [ ] - [(let [[amount set] (..aggregate (the ) ..languages)] - (_.coverage [] - (n.= amount (set.size set))))] - - [/.name #names text.hash] - [/.code #codes text.hash] - [/.equivalence #languages /.hash] - )) - ))))) - -(def !aliases - (template (_ ) - [(_.coverage - (list.every? (at /.equivalence = ) - (`` (list (,, (template.spliced ))))))])) - -(def aliases_test/0 - Test - (all _.and - ... A - (!aliases /.official_aramaic [/.imperial_aramaic]) - (!aliases /.asturian [/.bable /.leonese /.asturleonese]) - ... B - (!aliases /.bini [/.edo]) - (!aliases /.blin [/.bilin]) - ... C - (!aliases /.catalan [/.valencian]) - (!aliases /.church_slavic [/.old_slavonic /.church_slavonic /.old_bulgarian /.old_church_slavonic]) - ... D - (!aliases /.dhivehi [/.maldivian]) - ... G - (!aliases /.swiss_german [/.alemannic /.alsatian]) - ... I - (!aliases /.sichuan_yi [/.nuosu]) - ... K - (!aliases /.kachin [/.jingpho]) - (!aliases /.kalaallisut [/.greenlandic]) - (!aliases /.khotanese [/.sakan]) - )) - -(def aliases_test/1 - Test - (all _.and - ... M - (!aliases /.mi'kmaq [/.micmac]) - ... N - (!aliases /.newari [/.nepal_bhasa]) - (!aliases /.dutch [/.flemish]) - (!aliases /.northern_sotho [/.pedi /.sepedi]) - (!aliases /.old_newari [/.classical_newari /.classical_nepal_bhasa]) - (!aliases /.nyanja [/.chichewa /.chewa]) - ... O - (!aliases /.occitan [/.provencal]) - ... P - (!aliases /.pampanga [/.kapampangan]) - ... R - (!aliases /.rarotongan [/.cook_islands_maori]) - (!aliases /.romanian [/.moldavian /.moldovan]) - (!aliases /.aromanian [/.arumanian /.macedo_romanian]) - ... S - (!aliases /.spanish [/.castilian]) - ... X - (!aliases /.kalmyk [/.oirat]) - ... Z - (!aliases /.zaza [/.dimili /.dimli /.kirdki /.kirmanjki /.zazaki]) - )) - -(def aliases_test - Test - (all _.and - ..aliases_test/0 - ..aliases_test/1 - )) - -(def .public random - (Random /.Language) - (let [options (|> ..languages - (list#each (|>> (the #languages) set.list)) - list.together)] - (do [! random.monad] - [choice (at ! each (n.% (list.size options)) - random.nat)] - (in (maybe.trusted (list.item choice options)))))) - -(def .public test - Test - (<| (_.covering /._) - (_.for [/.Language]) - (all _.and - (_.for [/.hash] - ($hash.spec /.hash ..random)) - - ..languages_test - ..aliases_test - ))) diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux deleted file mode 100644 index 969fe32a1..000000000 --- a/stdlib/source/test/lux/locale/territory.lux +++ /dev/null @@ -1,227 +0,0 @@ -(.require - [library - [lux (.except) - ["_" test (.only Test)] - [abstract - [monad (.only do)] - [hash (.only Hash)] - [\\specification - ["$[0]" hash]]] - [control - ["[0]" maybe]] - [data - ["[0]" text] - [collection - ["[0]" set (.only Set)] - ["[0]" list (.use "[1]#[0]" functor mix)]]] - [math - ["[0]" random (.only Random)] - [number - ["n" nat]]] - [meta - [macro - ["[0]" template]]]]] - [\\library - ["[0]" /]]) - -(type Bundle - (Record - [#amount Nat - #names (Set Text) - #shorts (Set Text) - #longs (Set Text) - #numbers (Set Nat) - #territories (Set /.Territory) - #test Test])) - -(with_template [ ] - [(def - Bundle - (let [amount (template.amount ) - territories (`` (list (,, (template.spliced ))))] - [#amount amount - #names (|> territories (list#each /.name) (set.of_list text.hash)) - #shorts (|> territories (list#each /.short_code) (set.of_list text.hash)) - #longs (|> territories (list#each /.long_code) (set.of_list text.hash)) - #numbers (|> territories (list#each /.numeric_code) (set.of_list n.hash)) - #territories (|> territories (set.of_list /.hash)) - #test (_.coverage - true)]))] - - [territories/a [/.afghanistan /.aland_islands /.albania /.algeria /.american_samoa - /.andorra /.angola /.anguilla /.antarctica /.antigua - /.argentina /.armenia /.aruba /.australia /.austria - /.azerbaijan]] - [territories/b [/.the_bahamas /.bahrain /.bangladesh /.barbados /.belarus - /.belgium /.belize /.benin /.bermuda /.bhutan - /.bolivia /.bonaire /.bosnia /.botswana /.bouvet_island - /.brazil /.british_indian_ocean_territory /.brunei_darussalam /.bulgaria /.burkina_faso - /.burundi]] - [territories/c [/.cape_verde /.cambodia /.cameroon /.canada /.cayman_islands - /.central_african_republic /.chad /.chile /.china /.christmas_island - /.cocos_islands /.colombia /.comoros /.congo /.democratic_republic_of_the_congo - /.cook_islands /.costa_rica /.ivory_coast /.croatia /.cuba - /.curacao /.cyprus /.czech_republic]] - [territories/d [/.denmark /.djibouti /.dominica /.dominican_republic]] - [territories/e [/.ecuador /.egypt /.el_salvador /.equatorial_guinea /.eritrea - /.estonia /.eswatini /.ethiopia]] - [territories/f [/.falkland_islands /.faroe_islands /.fiji /.finland /.france - /.french_guiana /.french_polynesia /.french_southern_territories]] - [territories/g [/.gabon /.the_gambia /.georgia /.germany /.ghana - /.gibraltar /.greece /.greenland /.grenada /.guadeloupe - /.guam /.guatemala /.guernsey /.guinea /.guinea_bissau - /.guyana]] - [territories/h [/.haiti /.heard_island /.honduras /.hong_kong - /.hungary]] - [territories/i [/.iceland /.india /.indonesia /.iran /.iraq - /.ireland /.isle_of_man /.israel /.italy]] - [territories/j [/.jamaica /.japan /.jersey /.jordan]] - [territories/k [/.kazakhstan /.kenya /.kiribati /.north_korea /.south_korea - /.kuwait /.kyrgyzstan]] - [territories/l [/.laos /.latvia /.lebanon /.lesotho /.liberia - /.libya /.liechtenstein /.lithuania /.luxembourg]] - [territories/m [/.macau /.macedonia /.madagascar /.malawi /.malaysia - /.maldives /.mali /.malta /.marshall_islands /.martinique - /.mauritania /.mauritius /.mayotte /.mexico /.micronesia - /.moldova /.monaco /.mongolia /.montenegro /.montserrat - /.morocco /.mozambique /.myanmar]] - [territories/n [/.namibia /.nauru /.nepal /.netherlands /.new_caledonia - /.new_zealand /.nicaragua /.niger /.nigeria /.niue - /.norfolk_island /.northern_mariana_islands /.norway]] - [territories/o [/.oman]] - [territories/p [/.pakistan /.palau /.palestine /.panama /.papua_new_guinea - /.paraguay /.peru /.philippines /.pitcairn_islands /.poland - /.portugal /.puerto_rico]] - [territories/q [/.qatar]] - [territories/r [/.reunion /.romania /.russia /.rwanda]] - [territories/s [/.saint_barthelemy /.saint_helena /.saint_kitts /.saint_lucia /.saint_martin - /.saint_pierre /.saint_vincent /.samoa /.san_marino /.sao_tome - /.saudi_arabia /.senegal /.serbia /.seychelles /.sierra_leone - /.singapore /.sint_maarten /.slovakia /.slovenia /.solomon_islands - /.somalia /.south_africa /.south_georgia /.south_sudan /.spain - /.sri_lanka /.sudan /.suriname /.svalbard /.sweden - /.switzerland /.syria]] - [territories/t [/.taiwan /.tajikistan /.tanzania /.thailand /.east_timor - /.togo /.tokelau /.tonga /.trinidad /.tunisia - /.turkey /.turkmenistan /.turks /.tuvalu]] - [territories/u [/.uganda /.ukraine /.united_arab_emirates /.united_kingdom /.united_states_of_america - /.united_states_minor_outlying_islands /.uruguay /.uzbekistan]] - [territories/v [/.vanuatu /.vatican_city /.venezuela /.vietnam /.british_virgin_islands /.united_states_virgin_islands]] - [territories/w [/.wallis /.western_sahara]] - [territories/y [/.yemen]] - [territories/z [/.zambia /.zimbabwe]] - ) - -(def territories - (List Bundle) - (list ..territories/a - ..territories/b - ..territories/c - ..territories/d - ..territories/e - ..territories/f - ..territories/g - ..territories/h - ..territories/i - ..territories/j - ..territories/k - ..territories/l - ..territories/m - ..territories/n - ..territories/o - ..territories/p - ..territories/q - ..territories/r - ..territories/s - ..territories/t - ..territories/u - ..territories/v - ..territories/w - ..territories/y - ..territories/z)) - -(def (aggregate lens hash territories) - (All (_ a) (-> (-> Bundle (Set a)) - (Hash a) - (List Bundle) - [Nat (Set a)])) - (list#mix (function (_ bundle [amount set]) - [(n.+ amount (the #amount bundle)) - (set.union set (lens bundle))]) - [0 (set.empty hash)] - territories)) - -(def territories_test - Test - (|> ..territories - list.reversed - (list#each (the #test)) - (list#mix _.and - (`` (all _.and - (,, (with_template [ ] - [(let [[amount set] (..aggregate (the ) ..territories)] - (_.coverage [] - (n.= amount (set.size set))))] - - [/.name #names text.hash] - [/.short_code #shorts text.hash] - [/.long_code #longs text.hash] - [/.numeric_code #numbers n.hash] - [/.equivalence #territories /.hash] - )) - ))))) - -(def !aliases - (template (_ ) - [(_.coverage - (list.every? (at /.equivalence = ) - (`` (list (,, (template.spliced ))))))])) - -(def aliases_test - Test - (all _.and - ... A - (!aliases /.antigua [/.barbuda]) - ... B - (!aliases /.bonaire [/.sint_eustatius /.saba]) - (!aliases /.bosnia [/.herzegovina]) - ... H - (!aliases /.heard_island [/.mcdonald_islands]) - ... S - (!aliases /.saint_helena [/.ascension /.tristan_da_cunha]) - (!aliases /.saint_kitts [/.nevis]) - (!aliases /.saint_pierre [/.miquelon]) - (!aliases /.saint_vincent [/.the_grenadines]) - (!aliases /.sao_tome [/.principe]) - (!aliases /.south_georgia [/.south_sandwich_islands]) - (!aliases /.svalbard [/.jan_mayen]) - ... T - (!aliases /.trinidad [/.tobago]) - (!aliases /.turks [/.caicos_islands]) - ... U - (!aliases /.united_kingdom [/.northern_ireland]) - ... W - (!aliases /.wallis [/.futuna]) - )) - -(def .public random - (Random /.Territory) - (let [options (|> ..territories - (list#each (|>> (the #territories) set.list)) - list.together)] - (do [! random.monad] - [choice (at ! each (n.% (list.size options)) - random.nat)] - (in (maybe.trusted (list.item choice options)))))) - -(def .public test - Test - (<| (_.covering /._) - (_.for [/.Territory]) - (all _.and - (_.for [/.hash] - ($hash.spec /.hash ..random)) - - ..territories_test - ..aliases_test - ))) diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux index e0018ab8b..0f8c65711 100644 --- a/stdlib/source/test/lux/world.lux +++ b/stdlib/source/test/lux/world.lux @@ -16,7 +16,8 @@ ["[1]/[0]" http ["[1]/[0]" client] ["[1]/[0]" status]]] - ["[1][0]" time]]) + ["[1][0]" time] + ["[1][0]" locale]]) (def .public test Test @@ -30,4 +31,5 @@ /net/http/client.test /net/http/status.test /time.test + /locale.test )) diff --git a/stdlib/source/test/lux/world/locale.lux b/stdlib/source/test/lux/world/locale.lux new file mode 100644 index 000000000..b7c99d34a --- /dev/null +++ b/stdlib/source/test/lux/world/locale.lux @@ -0,0 +1,98 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)] + [\\specification + ["$[0]" equivalence] + ["$[0]" hash]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)]] + [data + ["[0]" text (.use "[1]#[0]" equivalence) + ["[0]" encoding (.only Encoding)]] + [collection + ["[0]" list]]]]] + ["[0]" / + ["[1][0]" language] + ["[1][0]" territory]] + [\\library + ["[0]" / (.only) + ["[0]" language (.only Language)] + ["[0]" territory (.only Territory)]]]) + +(def random_language + (Random Language) + (random.either (random#in language.afar) + (random#in language.zaza))) + +(def random_territory + (Random Territory) + (random.either (random#in territory.afghanistan) + (random#in territory.zimbabwe))) + +(def random_encoding + (Random Encoding) + (random.either (random#in encoding.ascii) + (random#in encoding.koi8_u))) + +(def random_locale + (Random /.Locale) + (do random.monad + [language ..random_language + territory ..random_territory + encoding ..random_encoding] + (in (/.locale language {.#Some territory} {.#Some encoding})))) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Locale]) + (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random_locale)) + (_.for [/.hash] + (do [! random.monad] + [fixed_language ..random_language + fixed_territory ..random_territory + fixed_encoding ..random_encoding] + (all _.and + (|> ..random_language + (at ! each (function (_ language) + (/.locale language {.#Some fixed_territory} {.#Some fixed_encoding}))) + ($hash.spec /.hash)) + (|> ..random_territory + (at ! each (function (_ territory) + (/.locale fixed_language {.#Some territory} {.#Some fixed_encoding}))) + ($hash.spec /.hash)) + (|> ..random_encoding + (at ! each (function (_ encoding) + (/.locale fixed_language {.#Some fixed_territory} {.#Some encoding}))) + ($hash.spec /.hash)) + ))) + + (do random.monad + [language ..random_language + territory ..random_territory + encoding ..random_encoding + .let [l_locale (/.locale language {.#None} {.#None}) + lt_locale (/.locale language {.#Some territory} {.#None}) + le_locale (/.locale language {.#None} {.#Some encoding}) + lte_locale (/.locale language {.#Some territory} {.#Some encoding})] + .let [language_check (and (text#= (language.code language) + (/.code l_locale)) + (list.every? (|>> /.code (text.starts_with? (language.code language))) + (list lt_locale le_locale lte_locale))) + territory_check (list.every? (|>> /.code (text.contains? (territory.long_code territory))) + (list lt_locale lte_locale)) + encoding_check (list.every? (|>> /.code (text.ends_with? (encoding.name encoding))) + (list le_locale lte_locale))]] + (_.coverage [/.locale /.code] + (and language_check + territory_check + encoding_check))) + + /language.test + /territory.test + ))) diff --git a/stdlib/source/test/lux/world/locale/language.lux b/stdlib/source/test/lux/world/locale/language.lux new file mode 100644 index 000000000..edabb90d2 --- /dev/null +++ b/stdlib/source/test/lux/world/locale/language.lux @@ -0,0 +1,301 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)] + [hash (.only Hash)] + [\\specification + ["$[0]" hash]]] + [control + ["[0]" maybe]] + [data + ["[0]" text] + [collection + ["[0]" set (.only Set)] + ["[0]" list (.use "[1]#[0]" functor mix)]]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [meta + [macro + ["[0]" template]]]]] + [\\library + ["[0]" /]]) + +(type Bundle + (Record + [#amount Nat + #names (Set Text) + #codes (Set Text) + #languages (Set /.Language) + #test Test])) + +(with_template [ ] + [(def + Bundle + (let [amount (template.amount ) + languages (is (List /.Language) + (`` (list (,, (template.spliced )))))] + [#amount amount + #names (|> languages (list#each /.name) (set.of_list text.hash)) + #codes (|> languages (list#each /.code) (set.of_list text.hash)) + #languages (set.of_list /.hash languages) + #test (_.coverage + true)]))] + + [languages/a [/.afar /.abkhazian /.achinese /.acoli /.adangme + /.adyghe /.afro_asiatic /.afrihili /.afrikaans /.ainu + /.akan /.akkadian /.aleut /.algonquian /.southern_altai + /.amharic /.old_english /.angika /.apache /.arabic + /.official_aramaic /.aragonese /.mapudungun /.arapaho /.artificial + /.arawak /.assamese /.asturian /.athapascan /.australian + /.avaric /.avestan /.awadhi /.aymara /.azerbaijani]] + [languages/b [/.banda /.bamileke /.bashkir /.baluchi /.bambara + /.balinese /.basa /.baltic /.beja /.belarusian + /.bemba /.bengali /.berber /.bhojpuri /.bihari + /.bikol /.bini /.bislama /.siksika /.bantu + /.tibetan /.bosnian /.braj /.breton /.batak + /.buriat /.buginese /.bulgarian /.blin]] + [languages/c [/.caddo /.central_american_indian /.galibi_carib /.catalan /.caucasian + /.cebuano /.celtic /.czech /.chamorro /.chibcha + /.chechen /.chagatai /.chuukese /.mari /.chinook + /.choctaw /.chipewyan /.cherokee /.church_slavic /.chuvash + /.cheyenne /.chamic /.montenegrin /.coptic /.cornish + /.corsican /.creoles_and_pidgins/english /.creoles_and_pidgins/french /.creoles_and_pidgins/portuguese /.cree + /.crimean /.creoles_and_pidgins /.kashubian /.cushitic /.welsh]] + [languages/d [/.dakota /.danish /.dargwa /.land_dayak /.delaware + /.slavey /.dogrib /.dinka /.dhivehi /.dogri + /.dravidian /.lower_sorbian /.duala /.middle_dutch /.dyula + /.dzongkha]] + [languages/e [/.efik /.egyptian /.ekajuk /.greek /.elamite + /.english /.middle_english /.esperanto /.estonian /.basque + /.ewe /.ewondo]] + [languages/f [/.fang /.faroese /.persian /.fanti /.fijian + /.filipino /.finnish /.finno_ugrian /.fon /.french + /.middle_french /.old_french /.northern_frisian /.eastern_frisian /.western_frisian + /.fulah /.friulian]] + [languages/g [/.ga /.gayo /.gbaya /.germanic /.german + /.geez /.gilbertese /.gaelic /.irish /.galician + /.manx /.middle_high_german /.old_high_german /.gondi /.gorontalo + /.gothic /.grebo /.ancient_greek /.guarani /.swiss_german + /.gujarati /.gwich'in]] + [languages/h [/.haida /.haitian /.hausa /.hawaiian /.hebrew + /.herero /.hiligaynon /.himachali /.hindi /.hittite + /.hmong /.hiri_motu /.croatian /.upper_sorbian /.hungarian + /.hupa /.armenian]] + [languages/i [/.iban /.igbo /.ido /.sichuan_yi /.ijo + /.inuktitut /.interlingue /.iloko /.interlingua /.indic + /.indonesian /.indo_european /.ingush /.inupiaq /.iranian + /.iroquoian /.icelandic /.italian]] + [languages/j [/.javanese /.lojban /.japanese /.judeo_persian /.judeo_arabic]] + [languages/k [/.kara_kalpak /.kabyle /.kachin /.kalaallisut /.kamba + /.kannada /.karen /.kashmiri /.georgian /.kanuri + /.kawi /.kazakh /.kabardian /.khasi /.khoisan + /.central_khmer /.khotanese /.gikuyu /.kinyarwanda /.kyrgyz + /.kimbundu /.konkani /.komi /.kongo /.korean + /.kosraean /.kpelle /.karachay_balkar /.karelian /.kru + /.kurukh /.kwanyama /.kumyk /.kurdish /.kutenai]] + [languages/l [/.ladino /.lahnda /.lamba /.lao /.latin + /.latvian /.lezghian /.limburgan /.lingala /.lithuanian + /.mongo /.lozi /.luxembourgish /.luba_lulua /.luba_katanga + /.ganda /.luiseno /.lunda /.luo /.lushai]] + [languages/m [/.madurese /.magahi /.marshallese /.maithili /.makasar + /.malayalam /.mandingo /.austronesian /.marathi /.masai + /.moksha /.mandar /.mende /.middle_irish /.mi'kmaq + /.minangkabau /.macedonian /.mon_khmer /.malagasy /.maltese + /.manchu /.manipuri /.manobo /.mohawk /.mongolian + /.mossi /.maori /.malay /.munda /.creek + /.mirandese /.marwari /.burmese /.mayan /.erzya]] + [languages/n [/.nahuatl /.north_american_indian /.neapolitan /.nauru /.navajo + /.south_ndebele /.north_ndebele /.ndonga /.low_german /.nepali + /.newari /.nias /.niger_kordofanian /.niuean /.dutch + /.nynorsk /.bokmal /.nogai /.old_norse /.norwegian + /.n'ko /.northern_sotho /.nubian /.old_newari /.nyanja + /.nyamwezi /.nyankole /.nyoro /.nzima]] + [languages/o [/.occitan /.ojibwa /.oriya /.oromo /.osage + /.ossetic /.ottoman_turkish /.otomian]] + [languages/p [/.papuan /.pangasinan /.pahlavi /.pampanga /.punjabi + /.papiamento /.palauan /.old_persian /.philippine /.phoenician + /.pali /.polish /.pohnpeian /.portuguese /.prakrit + /.old_provencal /.pashto]] + [languages/q [/.quechua]] + [languages/r [/.rajasthani /.rapanui /.rarotongan /.romance /.romansh + /.romany /.romanian /.rundi /.aromanian /.russian]] + [languages/s0 [/.sandawe /.sango /.yakut /.south_american_indian /.salishan + /.samaritan_aramaic /.sanskrit /.sasak /.santali /.sicilian + /.scots /.selkup /.semitic /.old_irish /.sign + /.shan /.sidamo /.sinhalese /.siouan /.sino_tibetan + /.slavic /.slovak /.slovenian /.southern_sami /.northern_sami + /.sami /.lule /.inari /.samoan /.skolt_sami]] + [languages/s1 [/.shona /.sindhi /.soninke /.sogdian /.somali + /.songhai /.southern_sotho /.spanish /.albanian /.sardinian + /.sranan_tongo /.serbian /.serer /.nilo_saharan /.swati + /.sukuma /.sundanese /.susu /.sumerian /.swahili + /.swedish /.classical_syriac /.syriac]] + [languages/t [/.tahitian /.tai /.tamil /.tatar /.telugu + /.timne /.tereno /.tetum /.tajik /.tagalog + /.thai /.tigre /.tigrinya /.tiv /.tokelau + /.klingon /.tlingit /.tamashek /.tonga /.tongan + /.tok_pisin /.tsimshian /.tswana /.tsonga /.turkmen + /.tumbuka /.tupi /.turkish /.altaic /.tuvalu + /.twi /.tuvinian]] + [languages/u [/.udmurt /.ugaritic /.uyghur /.ukrainian /.umbundu + /.urdu /.uzbek]] + [languages/v [/.vai /.venda /.vietnamese /.volapük /.votic]] + [languages/w [/.wakashan /.walamo /.waray /.washo /.sorbian + /.walloon /.wolof]] + [languages/x [/.kalmyk /.xhosa]] + [languages/y [/.yao /.yapese /.yiddish /.yoruba /.yupik]] + [languages/z [/.zapotec /.blissymbols /.zenaga /.standard_moroccan_tamazight /.zhuang + /.chinese /.zande /.zulu /.zuni /.zaza]] + [languages/etc [/.uncoded /.multiple /.undetermined /.not_applicable]] + ) + +(def languages + (List Bundle) + (list ..languages/a + ..languages/b + ..languages/c + ..languages/d + ..languages/e + ..languages/f + ..languages/g + ..languages/h + ..languages/i + ..languages/j + ..languages/k + ..languages/l + ..languages/m + ..languages/n + ..languages/o + ..languages/p + ..languages/q + ..languages/r + ..languages/s0 + ..languages/s1 + ..languages/t + ..languages/u + ..languages/v + ..languages/w + ..languages/x + ..languages/y + ..languages/z + ..languages/etc + )) + +(def (aggregate lens hash territories) + (All (_ a) (-> (-> Bundle (Set a)) + (Hash a) + (List Bundle) + [Nat (Set a)])) + (list#mix (function (_ bundle [amount set]) + [(n.+ amount (the #amount bundle)) + (set.union set (lens bundle))]) + [0 (set.empty hash)] + territories)) + +(def languages_test + Test + (|> ..languages + list.reversed + (list#each (the #test)) + (list#mix _.and + (`` (all _.and + (,, (with_template [ ] + [(let [[amount set] (..aggregate (the ) ..languages)] + (_.coverage [] + (n.= amount (set.size set))))] + + [/.name #names text.hash] + [/.code #codes text.hash] + [/.equivalence #languages /.hash] + )) + ))))) + +(def !aliases + (template (_ ) + [(_.coverage + (list.every? (at /.equivalence = ) + (`` (list (,, (template.spliced ))))))])) + +(def aliases_test/0 + Test + (all _.and + ... A + (!aliases /.official_aramaic [/.imperial_aramaic]) + (!aliases /.asturian [/.bable /.leonese /.asturleonese]) + ... B + (!aliases /.bini [/.edo]) + (!aliases /.blin [/.bilin]) + ... C + (!aliases /.catalan [/.valencian]) + (!aliases /.church_slavic [/.old_slavonic /.church_slavonic /.old_bulgarian /.old_church_slavonic]) + ... D + (!aliases /.dhivehi [/.maldivian]) + ... G + (!aliases /.swiss_german [/.alemannic /.alsatian]) + ... I + (!aliases /.sichuan_yi [/.nuosu]) + ... K + (!aliases /.kachin [/.jingpho]) + (!aliases /.kalaallisut [/.greenlandic]) + (!aliases /.khotanese [/.sakan]) + )) + +(def aliases_test/1 + Test + (all _.and + ... M + (!aliases /.mi'kmaq [/.micmac]) + ... N + (!aliases /.newari [/.nepal_bhasa]) + (!aliases /.dutch [/.flemish]) + (!aliases /.northern_sotho [/.pedi /.sepedi]) + (!aliases /.old_newari [/.classical_newari /.classical_nepal_bhasa]) + (!aliases /.nyanja [/.chichewa /.chewa]) + ... O + (!aliases /.occitan [/.provencal]) + ... P + (!aliases /.pampanga [/.kapampangan]) + ... R + (!aliases /.rarotongan [/.cook_islands_maori]) + (!aliases /.romanian [/.moldavian /.moldovan]) + (!aliases /.aromanian [/.arumanian /.macedo_romanian]) + ... S + (!aliases /.spanish [/.castilian]) + ... X + (!aliases /.kalmyk [/.oirat]) + ... Z + (!aliases /.zaza [/.dimili /.dimli /.kirdki /.kirmanjki /.zazaki]) + )) + +(def aliases_test + Test + (all _.and + ..aliases_test/0 + ..aliases_test/1 + )) + +(def .public random + (Random /.Language) + (let [options (|> ..languages + (list#each (|>> (the #languages) set.list)) + list.together)] + (do [! random.monad] + [choice (at ! each (n.% (list.size options)) + random.nat)] + (in (maybe.trusted (list.item choice options)))))) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Language]) + (all _.and + (_.for [/.hash] + ($hash.spec /.hash ..random)) + + ..languages_test + ..aliases_test + ))) diff --git a/stdlib/source/test/lux/world/locale/territory.lux b/stdlib/source/test/lux/world/locale/territory.lux new file mode 100644 index 000000000..969fe32a1 --- /dev/null +++ b/stdlib/source/test/lux/world/locale/territory.lux @@ -0,0 +1,227 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)] + [hash (.only Hash)] + [\\specification + ["$[0]" hash]]] + [control + ["[0]" maybe]] + [data + ["[0]" text] + [collection + ["[0]" set (.only Set)] + ["[0]" list (.use "[1]#[0]" functor mix)]]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [meta + [macro + ["[0]" template]]]]] + [\\library + ["[0]" /]]) + +(type Bundle + (Record + [#amount Nat + #names (Set Text) + #shorts (Set Text) + #longs (Set Text) + #numbers (Set Nat) + #territories (Set /.Territory) + #test Test])) + +(with_template [ ] + [(def + Bundle + (let [amount (template.amount ) + territories (`` (list (,, (template.spliced ))))] + [#amount amount + #names (|> territories (list#each /.name) (set.of_list text.hash)) + #shorts (|> territories (list#each /.short_code) (set.of_list text.hash)) + #longs (|> territories (list#each /.long_code) (set.of_list text.hash)) + #numbers (|> territories (list#each /.numeric_code) (set.of_list n.hash)) + #territories (|> territories (set.of_list /.hash)) + #test (_.coverage + true)]))] + + [territories/a [/.afghanistan /.aland_islands /.albania /.algeria /.american_samoa + /.andorra /.angola /.anguilla /.antarctica /.antigua + /.argentina /.armenia /.aruba /.australia /.austria + /.azerbaijan]] + [territories/b [/.the_bahamas /.bahrain /.bangladesh /.barbados /.belarus + /.belgium /.belize /.benin /.bermuda /.bhutan + /.bolivia /.bonaire /.bosnia /.botswana /.bouvet_island + /.brazil /.british_indian_ocean_territory /.brunei_darussalam /.bulgaria /.burkina_faso + /.burundi]] + [territories/c [/.cape_verde /.cambodia /.cameroon /.canada /.cayman_islands + /.central_african_republic /.chad /.chile /.china /.christmas_island + /.cocos_islands /.colombia /.comoros /.congo /.democratic_republic_of_the_congo + /.cook_islands /.costa_rica /.ivory_coast /.croatia /.cuba + /.curacao /.cyprus /.czech_republic]] + [territories/d [/.denmark /.djibouti /.dominica /.dominican_republic]] + [territories/e [/.ecuador /.egypt /.el_salvador /.equatorial_guinea /.eritrea + /.estonia /.eswatini /.ethiopia]] + [territories/f [/.falkland_islands /.faroe_islands /.fiji /.finland /.france + /.french_guiana /.french_polynesia /.french_southern_territories]] + [territories/g [/.gabon /.the_gambia /.georgia /.germany /.ghana + /.gibraltar /.greece /.greenland /.grenada /.guadeloupe + /.guam /.guatemala /.guernsey /.guinea /.guinea_bissau + /.guyana]] + [territories/h [/.haiti /.heard_island /.honduras /.hong_kong + /.hungary]] + [territories/i [/.iceland /.india /.indonesia /.iran /.iraq + /.ireland /.isle_of_man /.israel /.italy]] + [territories/j [/.jamaica /.japan /.jersey /.jordan]] + [territories/k [/.kazakhstan /.kenya /.kiribati /.north_korea /.south_korea + /.kuwait /.kyrgyzstan]] + [territories/l [/.laos /.latvia /.lebanon /.lesotho /.liberia + /.libya /.liechtenstein /.lithuania /.luxembourg]] + [territories/m [/.macau /.macedonia /.madagascar /.malawi /.malaysia + /.maldives /.mali /.malta /.marshall_islands /.martinique + /.mauritania /.mauritius /.mayotte /.mexico /.micronesia + /.moldova /.monaco /.mongolia /.montenegro /.montserrat + /.morocco /.mozambique /.myanmar]] + [territories/n [/.namibia /.nauru /.nepal /.netherlands /.new_caledonia + /.new_zealand /.nicaragua /.niger /.nigeria /.niue + /.norfolk_island /.northern_mariana_islands /.norway]] + [territories/o [/.oman]] + [territories/p [/.pakistan /.palau /.palestine /.panama /.papua_new_guinea + /.paraguay /.peru /.philippines /.pitcairn_islands /.poland + /.portugal /.puerto_rico]] + [territories/q [/.qatar]] + [territories/r [/.reunion /.romania /.russia /.rwanda]] + [territories/s [/.saint_barthelemy /.saint_helena /.saint_kitts /.saint_lucia /.saint_martin + /.saint_pierre /.saint_vincent /.samoa /.san_marino /.sao_tome + /.saudi_arabia /.senegal /.serbia /.seychelles /.sierra_leone + /.singapore /.sint_maarten /.slovakia /.slovenia /.solomon_islands + /.somalia /.south_africa /.south_georgia /.south_sudan /.spain + /.sri_lanka /.sudan /.suriname /.svalbard /.sweden + /.switzerland /.syria]] + [territories/t [/.taiwan /.tajikistan /.tanzania /.thailand /.east_timor + /.togo /.tokelau /.tonga /.trinidad /.tunisia + /.turkey /.turkmenistan /.turks /.tuvalu]] + [territories/u [/.uganda /.ukraine /.united_arab_emirates /.united_kingdom /.united_states_of_america + /.united_states_minor_outlying_islands /.uruguay /.uzbekistan]] + [territories/v [/.vanuatu /.vatican_city /.venezuela /.vietnam /.british_virgin_islands /.united_states_virgin_islands]] + [territories/w [/.wallis /.western_sahara]] + [territories/y [/.yemen]] + [territories/z [/.zambia /.zimbabwe]] + ) + +(def territories + (List Bundle) + (list ..territories/a + ..territories/b + ..territories/c + ..territories/d + ..territories/e + ..territories/f + ..territories/g + ..territories/h + ..territories/i + ..territories/j + ..territories/k + ..territories/l + ..territories/m + ..territories/n + ..territories/o + ..territories/p + ..territories/q + ..territories/r + ..territories/s + ..territories/t + ..territories/u + ..territories/v + ..territories/w + ..territories/y + ..territories/z)) + +(def (aggregate lens hash territories) + (All (_ a) (-> (-> Bundle (Set a)) + (Hash a) + (List Bundle) + [Nat (Set a)])) + (list#mix (function (_ bundle [amount set]) + [(n.+ amount (the #amount bundle)) + (set.union set (lens bundle))]) + [0 (set.empty hash)] + territories)) + +(def territories_test + Test + (|> ..territories + list.reversed + (list#each (the #test)) + (list#mix _.and + (`` (all _.and + (,, (with_template [ ] + [(let [[amount set] (..aggregate (the ) ..territories)] + (_.coverage [] + (n.= amount (set.size set))))] + + [/.name #names text.hash] + [/.short_code #shorts text.hash] + [/.long_code #longs text.hash] + [/.numeric_code #numbers n.hash] + [/.equivalence #territories /.hash] + )) + ))))) + +(def !aliases + (template (_ ) + [(_.coverage + (list.every? (at /.equivalence = ) + (`` (list (,, (template.spliced ))))))])) + +(def aliases_test + Test + (all _.and + ... A + (!aliases /.antigua [/.barbuda]) + ... B + (!aliases /.bonaire [/.sint_eustatius /.saba]) + (!aliases /.bosnia [/.herzegovina]) + ... H + (!aliases /.heard_island [/.mcdonald_islands]) + ... S + (!aliases /.saint_helena [/.ascension /.tristan_da_cunha]) + (!aliases /.saint_kitts [/.nevis]) + (!aliases /.saint_pierre [/.miquelon]) + (!aliases /.saint_vincent [/.the_grenadines]) + (!aliases /.sao_tome [/.principe]) + (!aliases /.south_georgia [/.south_sandwich_islands]) + (!aliases /.svalbard [/.jan_mayen]) + ... T + (!aliases /.trinidad [/.tobago]) + (!aliases /.turks [/.caicos_islands]) + ... U + (!aliases /.united_kingdom [/.northern_ireland]) + ... W + (!aliases /.wallis [/.futuna]) + )) + +(def .public random + (Random /.Territory) + (let [options (|> ..territories + (list#each (|>> (the #territories) set.list)) + list.together)] + (do [! random.monad] + [choice (at ! each (n.% (list.size options)) + random.nat)] + (in (maybe.trusted (list.item choice options)))))) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Territory]) + (all _.and + (_.for [/.hash] + ($hash.spec /.hash ..random)) + + ..territories_test + ..aliases_test + ))) -- cgit v1.2.3