aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux.lux3
-rw-r--r--stdlib/source/test/lux/control/writer.lux8
-rw-r--r--stdlib/source/test/lux/debug.lux4
-rw-r--r--stdlib/source/test/lux/world.lux3
-rw-r--r--stdlib/source/test/lux/world/money/currency.lux243
5 files changed, 254 insertions, 7 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index f009922e8..c86ef4fe0 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -56,8 +56,7 @@
["[1][0]" world]
- ["[1][0]" ffi]]
- )
+ ["[1][0]" ffi]])
(def for_bit
Test
diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux
index 1169c4922..a6c79032b 100644
--- a/stdlib/source/test/lux/control/writer.lux
+++ b/stdlib/source/test/lux/control/writer.lux
@@ -12,7 +12,6 @@
[control
["[0]" io]]
[data
- ["[0]" product]
["[0]" text (.use "[1]#[0]" equivalence)]]
[math
["[0]" random]
@@ -39,7 +38,8 @@
left random.nat
right random.nat]
(<| (_.covering /._)
- (_.for [/.Writer])
+ (_.for [/.Writer
+ /.#log /.#value])
(all _.and
(_.for [/.functor]
($functor.spec (..injection text.monoid) ..comparison /.functor))
@@ -50,7 +50,7 @@
(_.coverage [/.write]
(text#= log
- (product.left (/.write log))))
+ (the /.#log (/.write log))))
(_.coverage [/.with /.lifted]
(let [lifted (/.lifted text.monoid io.monad)
(open "io#[0]") io.monad]
@@ -59,6 +59,6 @@
b (in right)]
(in (n.+ a b)))
io.run!
- product.right
+ (the /.#value)
(n.= (n.+ left right)))))
))))
diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux
index bf54deb21..870809042 100644
--- a/stdlib/source/test/lux/debug.lux
+++ b/stdlib/source/test/lux/debug.lux
@@ -297,7 +297,9 @@
[(io/StringIO::getvalue buffer)
output])
@.lua [""
- <body>])]))
+ <body>]
+ @.ruby [""
+ <body>])]))
(def .public test
Test
diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux
index bfd4710b7..9ce864d44 100644
--- a/stdlib/source/test/lux/world.lux
+++ b/stdlib/source/test/lux/world.lux
@@ -13,6 +13,8 @@
["[1][0]" output
["[1]/[0]" video
["[1]/[0]" resolution]]]
+ ["[1][0]" money
+ ["[1]/[0]" currency]]
["[1][0]" net]
["[1][0]" time]
["[1][0]" locale]
@@ -27,6 +29,7 @@
/environment.test
/input/keyboard.test
/output/video/resolution.test
+ /money/currency.test
/net.test
/time.test
/locale.test
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>
+ ))
+ )))
+ ))))