aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world
diff options
context:
space:
mode:
authorEduardo Julian2022-11-28 15:35:57 -0400
committerEduardo Julian2022-11-28 15:35:57 -0400
commit8059ba6c421d3094fba336ac5d3dd39fe984b05e (patch)
tree416a27d5a5ae1db02afb2caa681c6e321c7b8f90 /stdlib/source/test/lux/world
parent09a29c952edb851e13edd454bd118c1c1ae83ade (diff)
Added currencies.
Diffstat (limited to 'stdlib/source/test/lux/world')
-rw-r--r--stdlib/source/test/lux/world/money/currency.lux243
1 files changed, 243 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/world/money/currency.lux b/stdlib/source/test/lux/world/money/currency.lux
new file mode 100644
index 000000000..0edb4b33c
--- /dev/null
+++ b/stdlib/source/test/lux/world/money/currency.lux
@@ -0,0 +1,243 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]]
+ [data
+ ["[0]" text]
+ [collection
+ ["[0]" list (.use "[1]#[0]" functor)]
+ ["[0]" set]]]
+ [math
+ ["[0]" random (.only Random)]
+ [number
+ ["n" nat]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" /]])
+
+(with_expansions [<currencies> (these [/.aed /.AED /.united_arab_emirates_dirham]
+ [/.afn /.AFN /.afghan_afghani]
+ [/.all /.ALL /.albanian_lek]
+ [/.amd /.AMD /.armenian_dram]
+ [/.ang /.ANG /.netherlands_antillean_guilder]
+ [/.aoa /.AOA /.angolan_kwanza]
+ [/.ars /.ARS /.argentine_peso]
+ [/.aud /.AUD /.australian_dollar]
+ [/.awg /.AWG /.aruban_florin]
+ [/.azn /.AZN /.azerbaijani_manat]
+ [/.bam /.BAM /.bosnia_and_herzegovina_convertible_mark]
+
+ [/.bbd /.BBD /.barbados_dollar]
+ [/.bdt /.BDT /.bangladeshi_taka]
+ [/.bgn /.BGN /.bulgarian_lev]
+ [/.bhd /.BHD /.bahraini_dinar]
+ [/.bif /.BIF /.burundian_franc]
+ [/.bmd /.BMD /.bermudian_dollar]
+ [/.bnd /.BND /.brunei_dollar]
+ [/.bob /.BOB /.boliviano]
+ [/.brl /.BRL /.brazilian_real]
+ [/.bsd /.BSD /.bahamian_dollar]
+ [/.btn /.BTN /.bhutanese_ngultrum]
+ [/.bwp /.BWP /.botswana_pula]
+ [/.byn /.BYN /.belarusian_ruble]
+ [/.bzd /.BZD /.belize_dollar]
+
+ [/.cad /.CAD /.canadian_dollar]
+ [/.cdf /.CDF /.congolese_franc]
+ [/.chf /.CHF /.swiss_franc]
+ [/.clp /.CLP /.chilean_peso]
+ [/.cop /.COP /.colombian_peso]
+ [/.crc /.CRC /.costa_rican_colon]
+ [/.cuc /.CUC /.cuban_convertible_peso]
+ [/.cup /.CUP /.cuban_peso]
+ [/.cve /.CVE /.cape_verdean_escudo]
+ [/.czk /.CZK /.czech_koruna]
+
+ [/.djf /.DJF /.djiboutian_franc]
+ [/.dkk /.DKK /.danish_krone]
+ [/.dop /.DOP /.dominican_peso]
+ [/.dzd /.DZD /.algerian_dinar]
+
+ [/.egp /.EGP /.egyptian_pound]
+ [/.ern /.ERN /.eritrean_nakfa]
+ [/.etb /.ETB /.ethiopian_birr]
+ [/.eur /.EUR /.euro]
+
+ [/.fjd /.FJD /.fiji_dollar]
+ [/.fkp /.FKP /.falkland_islands_pound]
+
+ [/.gbp /.GBP /.pound_sterling]
+ [/.gel /.GEL /.georgian_lari]
+ [/.ghs /.GHS /.ghanaian_cedi]
+ [/.gip /.GIP /.gibraltar_pound]
+ [/.gmd /.GMD /.gambian_dalasi]
+ [/.gnf /.GNF /.guinean_franc]
+ [/.gtq /.GTQ /.guatemalan_quetzal]
+ [/.gyd /.GYD /.guyanese_dollar]
+
+ [/.hkd /.HKD /.hong_kong_dollar]
+ [/.hnl /.HNL /.honduran_lempira]
+ [/.hrk /.HRK /.croatian_kuna]
+ [/.htg /.HTG /.haitian_gourde]
+ [/.huf /.HUF /.hungarian_forint]
+
+ [/.idr /.IDR /.indonesian_rupiah]
+ [/.ils /.ILS /.israeli_new_shekel]
+ [/.inr /.INR /.indian_rupee]
+ [/.iqd /.IQD /.iraqi_dinar]
+ [/.irr /.IRR /.iranian_rial]
+ [/.isk /.ISK /.icelandic_krona]
+
+ [/.jmd /.JMD /.jamaican_dollar]
+ [/.jod /.JOD /.jordanian_dinar]
+ [/.jpy /.JPY /.japanese_yen]
+
+ [/.kes /.KES /.kenyan_shilling]
+ [/.kgs /.KGS /.kyrgyzstani_som]
+ [/.khr /.KHR /.cambodian_riel]
+ [/.kmf /.KMF /.comoro_franc]
+ [/.kpw /.KPW /.north_korean_won]
+ [/.krw /.KRW /.south_korean_won]
+ [/.kwd /.KWD /.kuwaiti_dinar]
+ [/.kyd /.KYD /.cayman_islands_dollar]
+ [/.kzt /.KZT /.kazakhstani_tenge]
+
+ [/.lak /.LAK /.lao_kip]
+ [/.lbp /.LBP /.lebanese_pound]
+ [/.lkr /.LKR /.sri_lankan_rupee]
+ [/.lrd /.LRD /.liberian_dollar]
+ [/.lsl /.LSL /.lesotho_loti]
+ [/.lyd /.LYD /.libyan_dinar]
+
+ [/.mad /.MAD /.moroccan_dirham]
+ [/.mdl /.MDL /.moldovan_leu]
+ [/.mga /.MGA /.malagasy_ariary]
+ [/.mkd /.MKD /.macedonian_denar]
+ [/.mmk /.MMK /.myanmar_kyat]
+ [/.mnt /.MNT /.mongolian_togrog]
+ [/.mop /.MOP /.macanese_pataca]
+ [/.mru /.MRU /.mauritanian_ouguiya]
+ [/.mur /.MUR /.mauritian_rupee]
+ [/.mvr /.MVR /.maldivian_rufiyaa]
+ [/.mwk /.MWK /.malawian_kwacha]
+ [/.mxn /.MXN /.mexican_peso]
+ [/.myr /.MYR /.malaysian_ringgit]
+ [/.mzn /.MZN /.mozambican_metical]
+
+ [/.nad /.NAD /.namibian_dollar]
+ [/.ngn /.NGN /.nigerian_naira]
+ [/.nio /.NIO /.nicaraguan_cordoba]
+ [/.nok /.NOK /.norwegian_krone]
+ [/.npr /.NPR /.nepalese_rupee]
+ [/.nzd /.NZD /.new_zealand_dollar]
+
+ [/.omr /.OMR /.omani_rial]
+
+ [/.pab /.PAB /.panamanian_balboa]
+ [/.pen /.PEN /.peruvian_sol]
+ [/.pgk /.PGK /.papua_new_guinean_kina]
+ [/.php /.PHP /.philippine_peso]
+ [/.pkr /.PKR /.pakistani_rupee]
+ [/.pln /.PLN /.polish_ztoty]
+ [/.pyg /.PYG /.paraguayan_guarani]
+
+ [/.qar /.QAR /.qatari_riyal]
+
+ [/.ron /.RON /.romanian_leu]
+ [/.rsd /.RSD /.serbian_dinar]
+ [/.cny /.CNY /.renminbi]
+ [/.rub /.RUB /.russian_ruble]
+ [/.rwf /.RWF /.rwandan_franc]
+
+ [/.sar /.SAR /.saudi_riyal]
+ [/.sbd /.SBD /.solomon_islands_dollar]
+ [/.scr /.SCR /.seychelles_rupee]
+ [/.sdg /.SDG /.sudanese_pound]
+ [/.sek /.SEK /.swedish_krona]
+ [/.sgd /.SGD /.singapore_dollar]
+ [/.shp /.SHP /.saint_helena_pound]
+ [/.sos /.SOS /.somali_shilling]
+ [/.srd /.SRD /.surinamese_dollar]
+ [/.ssp /.SSP /.south_sudanese_pound]
+ [/.stn /.STN /.sao_tome_and_principe_dobra]
+ [/.svc /.SVC /.salvadoran_colon]
+ [/.syp /.SYP /.syrian_pound]
+ [/.szl /.SZL /.swazi_lilangeni]
+
+ [/.thb /.THB /.thai_baht]
+ [/.tjs /.TJS /.tajikistani_somoni]
+ [/.tmt /.TMT /.turkmenistan_manat]
+ [/.tnd /.TND /.tunisian_dinar]
+ [/.top /.TOP /.tongan_pa'anga]
+ [/.try /.TRY /.turkish_lira]
+ [/.ttd /.TTD /.trinidad_and_tobago_dollar]
+ [/.twd /.TWD /.new_taiwan_dollar]
+ [/.tzs /.TZS /.tanzanian_shilling]
+
+ [/.uah /.UAH /.ukrainian_hryvnia]
+ [/.ugx /.UGX /.ugandan_shilling]
+ [/.usd /.USD /.united_states_dollar]
+ [/.uyu /.UYU /.uruguayan_peso]
+ [/.uzs /.UZS /.uzbekistan_sum]
+ [/.ves /.VES /.venezuelan_sovereign_bolivar]
+ [/.vnd /.VND /.vietnamese_dong]
+ [/.vuv /.VUV /.vanuatu_vatu]
+ [/.wst /.WST /.samoan_tala]
+
+ [/.xag /.XAG /.silver]
+ [/.xau /.XAU /.gold]
+ [/.xcd /.XCD /.east_caribbean_dollar]
+ [/.xpd /.XPD /.palladium]
+ [/.xpt /.XPT /.platinum]
+
+ [/.zar /.ZAR /.south_african_rand]
+ [/.zmw /.ZMW /.zambian_kwacha]
+ [/.zwl /.ZWL /.zimbabwean_dollar]
+ )]
+ (def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [])
+ (_.for [/.Currency])
+ (all _.and
+ (with_expansions [<shorts> (with_template [<short> <type> <long>]
+ [<short>]
+
+ <currencies>
+ )]
+ (<| (_.for [<shorts>])
+ (let [options (is (List (/.Currency Any))
+ (list <shorts>))])
+ (all _.and
+ (_.coverage [/.alphabetic_code]
+ (let [uniques (|> options
+ (list#each /.alphabetic_code)
+ (set.of_list text.hash))]
+ (n.= (list.size options)
+ (set.size uniques))))
+ (_.coverage [/.numeric_code]
+ (let [uniques (|> options
+ (list#each /.numeric_code)
+ (set.of_list n.hash))]
+ (n.= (list.size options)
+ (set.size uniques))))
+ (_.coverage [/.decimals]
+ (list.every? (|>> /.decimals (n.<= 3))
+ options))
+ )))
+ (<| (_.for [/.currency /.type])
+ (`` (all _.and
+ (,, (with_template [<short> <type> <long>]
+ [(_.coverage [<type> <long>]
+ (same? (is (/.Currency <type>)
+ <short>)
+ (is (/.Currency <type>)
+ <long>)))]
+
+ <currencies>
+ ))
+ )))
+ ))))