aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/finance/money/currency.lux
blob: ee95bf2f073fd23365689dffb6f4f5d70bb45843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]
    ["[0]" equivalence
     ["[1]T" \\test]]]
   [data
    ["[0]" text]
    [collection
     ["[0]" list (.use "[1]#[0]" functor)]
     ["[0]" set]]]
   [math
    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
    [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 random
    (Random (Ex (_ of)
              (/.Currency of)))
    (`` (all random.either
             (,, (with_template [<short> <type> <long>]
                   [(random#in <short>)]
                   
                   <currencies>
                   ))
             )))
  
  (def .public test
    Test
    (<| (_.covering /._)
        (do [! random.monad]
          [])
        (_.for [/.Currency])
        (all _.and
             (_.for [/.equivalence]
                    (equivalenceT.spec /.equivalence ..random))
             
             (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 [/.sub_divisions]
                          (list.every? (|>> /.sub_divisions (n.> 0))
                                       options))
                        )))
             (<| (_.for [/.currency /.type])
                 (`` (all _.and
                          (,, (with_template [<short> <type> <long>]
                                [(_.coverage [<type> <long>]
                                   (same? (is (/.Currency <type>)
                                              <short>)
                                          (is (/.Currency <type>)
                                              <long>)))]

                                <currencies>
                                ))
                          )))
             ))))