aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/locale/territory.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/locale/territory.lux')
-rw-r--r--stdlib/source/test/lux/locale/territory.lux21
1 files changed, 19 insertions, 2 deletions
diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux
index 4fe08f75a..4fc425804 100644
--- a/stdlib/source/test/lux/locale/territory.lux
+++ b/stdlib/source/test/lux/locale/territory.lux
@@ -3,8 +3,12 @@
["_" test (#+ Test)]
[abstract
[monad (#+ do)]
- [hash (#+ Hash)]]
+ [hash (#+ Hash)]
+ {[0 #spec]
+ [/
+ ["$." hash]]}]
[data
+ ["." maybe]
["." text]
[number
["n" nat]]
@@ -14,7 +18,7 @@
[macro
["." template]]
[math
- ["." random]]]
+ ["." random (#+ Random)]]]
{1
["." /]})
@@ -196,11 +200,24 @@
(!aliases /.wallis [/.futuna])
))
+(def: #export random
+ (Random /.Territory)
+ (let [options (|> ..territories
+ (list\map (|>> (get@ #territories) set.to-list))
+ list.concat)]
+ (do {! random.monad}
+ [choice (\ ! map (n.% (list.size options))
+ random.nat)]
+ (wrap (maybe.assume (list.nth choice options))))))
+
(def: #export test
Test
(<| (_.covering /._)
(_.for [/.Territory])
($_ _.and
+ (_.for [/.hash]
+ ($hash.spec /.hash ..random))
+
..territories-test
..aliases-test
)))