aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2020-12-11 22:40:31 -0400
committerEduardo Julian2020-12-11 22:40:31 -0400
commitdff517cbdb9a1c80028782c62ad91c71ddb34909 (patch)
treef69b4005e8b6dc9699a410554ce4571f60d9e0ee /stdlib/source/test
parent9af671a34728b35c48bff2ba163c371dc5084946 (diff)
Improved parsing speed for Lux code.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/aedifex.lux5
-rw-r--r--stdlib/source/test/aedifex/command/deploy.lux2
-rw-r--r--stdlib/source/test/aedifex/command/pom.lux2
-rw-r--r--stdlib/source/test/aedifex/dependency/resolution.lux30
-rw-r--r--stdlib/source/test/aedifex/input.lux2
-rw-r--r--stdlib/source/test/aedifex/metadata/artifact.lux69
-rw-r--r--stdlib/source/test/lux/control/parser/binary.lux16
-rw-r--r--stdlib/source/test/lux/data/color/named.lux4
-rw-r--r--stdlib/source/test/lux/data/format/tar.lux2
-rw-r--r--stdlib/source/test/lux/data/format/xml.lux4
-rw-r--r--stdlib/source/test/lux/data/number/frac.lux8
-rw-r--r--stdlib/source/test/lux/data/number/i64.lux5
-rw-r--r--stdlib/source/test/lux/data/number/int.lux11
-rw-r--r--stdlib/source/test/lux/data/number/nat.lux11
-rw-r--r--stdlib/source/test/lux/data/number/rev.lux8
-rw-r--r--stdlib/source/test/lux/data/text.lux2
-rw-r--r--stdlib/source/test/lux/data/text/encoding.lux224
-rw-r--r--stdlib/source/test/lux/locale/language.lux23
-rw-r--r--stdlib/source/test/lux/locale/territory.lux21
19 files changed, 386 insertions, 63 deletions
diff --git a/stdlib/source/test/aedifex.lux b/stdlib/source/test/aedifex.lux
index 9166a4367..704faffbb 100644
--- a/stdlib/source/test/aedifex.lux
+++ b/stdlib/source/test/aedifex.lux
@@ -30,7 +30,9 @@
["#." parser]
["#." pom]
["#." repository]
- ["#." runtime]])
+ ["#." runtime]
+ ["#." metadata #_
+ ["#/." artifact]]])
(def: test
Test
@@ -59,6 +61,7 @@
/pom.test
/repository.test
/runtime.test
+ /metadata/artifact.test
))
(program: args
diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux
index eafd1f968..ef08ba39e 100644
--- a/stdlib/source/test/aedifex/command/deploy.lux
+++ b/stdlib/source/test/aedifex/command/deploy.lux
@@ -123,7 +123,7 @@
deployed-pom!
(\ binary.equivalence =
- (|> expected-pom (\ xml.codec encode) encoding.to-utf8)
+ (|> expected-pom (\ xml.codec encode) (\ encoding.utf8 encode))
actual-pom)
deployed-sha-1!
diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux
index d63641e04..d179031ea 100644
--- a/stdlib/source/test/aedifex/command/pom.lux
+++ b/stdlib/source/test/aedifex/command/pom.lux
@@ -46,7 +46,7 @@
(do !
[verdict (do ///action.monad
[expected (|> (///pom.write sample)
- (try\map (|>> (\ xml.codec encode) encoding.to-utf8))
+ (try\map (|>> (\ xml.codec encode) (\ encoding.utf8 encode)))
(\ ! wrap))
file (: (Promise (Try (File Promise)))
(file.get-file promise.monad fs path))
diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux
index 08bbaa4a4..c3e26f5bf 100644
--- a/stdlib/source/test/aedifex/dependency/resolution.lux
+++ b/stdlib/source/test/aedifex/dependency/resolution.lux
@@ -67,19 +67,19 @@
(#try.Success [state (|> package
(get@ #///package.pom)
(\ xml.codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.sha-1)
(#try.Success [state (|> package
(get@ #///package.sha-1)
(\ ///hash.sha-1-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.md5)
(#try.Success [state (|> package
(get@ #///package.md5)
(\ ///hash.md5-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
## else
(#try.Failure "NOPE"))
@@ -109,19 +109,19 @@
(#try.Success [state (|> expected-package
(get@ #///package.pom)
(\ xml.codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.sha-1)
(#try.Success [state (|> dummy-package
(get@ #///package.sha-1)
(\ ///hash.sha-1-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.md5)
(#try.Success [state (|> expected-package
(get@ #///package.md5)
(\ ///hash.md5-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
## else
(#try.Failure "NOPE"))
@@ -139,19 +139,19 @@
(#try.Success [state (|> expected-package
(get@ #///package.pom)
(\ xml.codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.sha-1)
(#try.Success [state (|> expected-package
(get@ #///package.sha-1)
(\ ///hash.sha-1-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.md5)
(#try.Success [state (|> dummy-package
(get@ #///package.md5)
(\ ///hash.md5-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
## else
(#try.Failure "NOPE"))
@@ -214,19 +214,19 @@
(#try.Success [state (|> expected-package
(get@ #///package.pom)
(\ xml.codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.sha-1)
(#try.Success [state (|> dummy-package
(get@ #///package.sha-1)
(\ ///hash.sha-1-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.md5)
(#try.Success [state (|> expected-package
(get@ #///package.md5)
(\ ///hash.md5-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
## else
(#try.Failure "NOPE"))
@@ -244,19 +244,19 @@
(#try.Success [state (|> expected-package
(get@ #///package.pom)
(\ xml.codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.sha-1)
(#try.Success [state (|> expected-package
(get@ #///package.sha-1)
(\ ///hash.sha-1-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
(text\= extension ///artifact/extension.md5)
(#try.Success [state (|> dummy-package
(get@ #///package.md5)
(\ ///hash.md5-codec encode)
- encoding.to-utf8)])
+ (\ encoding.utf8 encode))])
## else
(#try.Failure "NOPE"))
diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux
index dc424afc8..a0db21ba6 100644
--- a/stdlib/source/test/aedifex/input.lux
+++ b/stdlib/source/test/aedifex/input.lux
@@ -50,7 +50,7 @@
_ (|> expected
//format.profile
%.code
- encoding.to-utf8
+ (\ encoding.utf8 encode)
(!.use (\ file over-write)))
actual (: (Promise (Try Profile))
(/.read promise.monad fs //.default))]
diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux
new file mode 100644
index 000000000..bb105f305
--- /dev/null
+++ b/stdlib/source/test/aedifex/metadata/artifact.lux
@@ -0,0 +1,69 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]]}]
+ [control
+ ["." try ("#\." functor)]
+ [parser
+ ["<.>" xml]]]
+ [data
+ [number
+ ["n" nat]]]
+ ["." time
+ ["." date]
+ ["." year]
+ ["." month]
+ ["." instant]
+ ["." duration]]
+ [math
+ ["." random (#+ Random)]]
+ [macro
+ ["." code]]]
+ {#program
+ ["." /]})
+
+(def: #export random
+ (Random /.Metadata)
+ ($_ random.and
+ (random.ascii/alpha 5)
+ (random.ascii/alpha 5)
+ (random.list 5 (random.ascii/alpha 5))
+ (do {! random.monad}
+ [year (\ ! map (|>> (n.% 10,000) .int) random.nat)
+ month (\ ! map (n.% 13) random.nat)
+ day-of-month (\ ! map (n.% 29) random.nat)
+ hour (\ ! map (n.% 24) random.nat)
+ minute (\ ! map (n.% 60) random.nat)
+ second (\ ! map (n.% 60) random.nat)]
+ (wrap (try.assume
+ (do try.monad
+ [year (year.year year)
+ month (month.by-number month)
+ date (date.date year month day-of-month)
+ time (time.time
+ {#time.hour hour
+ #time.minute minute
+ #time.second second
+ #time.milli-second 0})]
+ (wrap (instant.from-date-time date time))))))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Metadata])
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (do random.monad
+ [expected ..random]
+ (_.cover [/.write /.parser]
+ (|> expected
+ /.write
+ (<xml>.run /.parser)
+ (try\map (\ /.equivalence = expected))
+ (try.default false))))
+ )))
diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux
index b967df5db..88c4aafaa 100644
--- a/stdlib/source/test/lux/control/parser/binary.lux
+++ b/stdlib/source/test/lux/control/parser/binary.lux
@@ -52,8 +52,8 @@
(def: (utf8-conversion-does-not-alter? value)
(Predicate Text)
(|> value
- encoding.to-utf8
- encoding.from-utf8
+ (\ encoding.utf8 encode)
+ (\ encoding.utf8 decode)
(case> (#try.Success converted)
(text\= value converted)
@@ -146,7 +146,7 @@
(`` ($_ _.and
(~~ (template [<parser> <format>]
[(do {! random.monad}
- [expected (\ ! map encoding.to-utf8 (random.ascii ..segment-size))]
+ [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))]
(_.cover [<parser> <format>]
(|> (format.run <format> expected)
(/.run <parser>)
@@ -327,14 +327,14 @@
(/.run /.any)
(!expect (#try.Success _))))
(do {! random.monad}
- [data (\ ! map encoding.to-utf8 (random.ascii ..segment-size))]
+ [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))]
(_.cover [/.binary-was-not-fully-read]
(|> data
(/.run /.any)
(!expect (^multi (#try.Failure error)
(exception.match? /.binary-was-not-fully-read error))))))
(do {! random.monad}
- [expected (\ ! map encoding.to-utf8 (random.ascii ..segment-size))]
+ [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))]
(_.cover [/.segment format.segment format.run]
(|> expected
(format.run (format.segment ..segment-size))
@@ -342,7 +342,7 @@
(!expect (^multi (#try.Success actual)
(\ binary.equivalence = expected actual))))))
(do {! random.monad}
- [data (\ ! map encoding.to-utf8 (random.ascii ..segment-size))]
+ [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))]
(_.cover [/.end?]
(|> data
(/.run (do <>.monad
@@ -354,7 +354,7 @@
(!expect (#try.Success #1)))))
(do {! random.monad}
[to-read (\ ! map (n.% (inc ..segment-size)) random.nat)
- data (\ ! map encoding.to-utf8 (random.ascii ..segment-size))]
+ data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))]
(_.cover [/.Offset /.offset]
(|> data
(/.run (do <>.monad
@@ -369,7 +369,7 @@
(!expect (#try.Success #1)))))
(do {! random.monad}
[to-read (\ ! map (n.% (inc ..segment-size)) random.nat)
- data (\ ! map encoding.to-utf8 (random.ascii ..segment-size))]
+ data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))]
(_.cover [/.remaining]
(|> data
(/.run (do <>.monad
diff --git a/stdlib/source/test/lux/data/color/named.lux b/stdlib/source/test/lux/data/color/named.lux
index fce2e0d90..0420eed19 100644
--- a/stdlib/source/test/lux/data/color/named.lux
+++ b/stdlib/source/test/lux/data/color/named.lux
@@ -219,8 +219,8 @@
(template [<definition> <by-letter>]
[(def: <definition>
Test
- (`` (_.cover <by-letter>
- ..verdict)))]
+ (_.cover <by-letter>
+ ..verdict))]
<colors>)
diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux
index fc92947ff..f837c0d18 100644
--- a/stdlib/source/test/lux/data/format/tar.lux
+++ b/stdlib/source/test/lux/data/format/tar.lux
@@ -159,7 +159,7 @@
#let [content (|> chunk
(list.repeat chunks)
(text.join-with "")
- encoding.to-utf8)]]
+ (\ encoding.utf8 encode))]]
(`` ($_ _.and
(~~ (template [<type> <tag>]
[(_.cover [<type>]
diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux
index e649040c1..a263b2a82 100644
--- a/stdlib/source/test/lux/data/format/xml.lux
+++ b/stdlib/source/test/lux/data/format/xml.lux
@@ -1,6 +1,5 @@
(.module:
[lux (#- char)
- ["%" data/text/format (#+ format)]
["_" test (#+ Test)]
[abstract
[monad (#+ Monad do)]
@@ -16,7 +15,8 @@
[data
["." name]
["." maybe]
- ["." text ("#\." equivalence)]
+ ["." text ("#\." equivalence)
+ ["%" format (#+ format)]]
[number
["n" nat]]
[collection
diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux
index f29cf93b1..ec3e4d3da 100644
--- a/stdlib/source/test/lux/data/number/frac.lux
+++ b/stdlib/source/test/lux/data/number/frac.lux
@@ -8,6 +8,7 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." hash]
["$." order]
["$." monoid]
["$." codec]]}]
@@ -95,6 +96,8 @@
(`` ($_ _.and
(_.for [/.equivalence /.=]
($equivalence.spec /.equivalence random.safe-frac))
+ (_.for [/.hash]
+ ($hash.spec /.hash random.frac))
(_.for [/.order /.<]
($order.spec /.order random.safe-frac))
(~~ (template [<compose> <monoid>]
@@ -232,11 +235,6 @@
(|> expected /.negate /.negate (/.= expected))]
(and subtraction!
inverse!))))
- (do random.monad
- [sample random.frac]
- (_.cover [/.hash]
- (n.= (/.to-bits sample)
- (\ /.hash hash sample))))
..constant
..predicate
diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux
index 12b935bef..78b293fd5 100644
--- a/stdlib/source/test/lux/data/number/i64.lux
+++ b/stdlib/source/test/lux/data/number/i64.lux
@@ -11,6 +11,7 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." hash]
["$." monoid]]}]
[math
["." random (#+ Random)]]]
@@ -167,6 +168,8 @@
($_ _.and
(_.for [/.equivalence]
($equivalence.spec /.equivalence random.i64))
+ (_.for [/.hash]
+ ($hash.spec /.hash random.i64))
(_.for [/.disjunction]
($monoid.spec n.equivalence /.disjunction random.nat))
(_.for [/.conjunction]
@@ -270,8 +273,6 @@
pattern)]
(\= (/.reverse high)
low)))))
- (_.cover [/.hash]
- (n.= pattern (\ /.hash hash pattern)))
..bit
..shift
diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux
index 02d44e282..33b2927e4 100644
--- a/stdlib/source/test/lux/data/number/int.lux
+++ b/stdlib/source/test/lux/data/number/int.lux
@@ -6,6 +6,7 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." hash]
["$." order]
["$." enum]
["$." interval]
@@ -14,8 +15,7 @@
[data
["." bit ("#\." equivalence)]
[number
- ["f" frac]
- ["." i64 ("#\." hash)]]]
+ ["f" frac]]]
[math
["." random (#+ Random)]]]
{1
@@ -26,6 +26,8 @@
(`` ($_ _.and
(_.for [/.equivalence /.=]
($equivalence.spec /.equivalence random.int))
+ (_.for [/.hash]
+ ($hash.spec /.hash random.int))
(_.for [/.order /.<]
($order.spec /.order random.int))
(_.for [/.enum]
@@ -160,11 +162,6 @@
[expected (\ ! map (/.% +1,000,000) random.int)]
(_.cover [/.frac]
(|> expected /.frac f.int (/.= expected))))
- (do random.monad
- [sample random.int]
- (_.cover [/.hash]
- (i64\= (i64\hash sample)
- (\ /.hash hash sample))))
..predicate
..signature
diff --git a/stdlib/source/test/lux/data/number/nat.lux b/stdlib/source/test/lux/data/number/nat.lux
index d53ca4631..97f93dc53 100644
--- a/stdlib/source/test/lux/data/number/nat.lux
+++ b/stdlib/source/test/lux/data/number/nat.lux
@@ -6,6 +6,7 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." hash]
["$." order]
["$." enum]
["$." interval]
@@ -14,8 +15,7 @@
[data
["." bit ("#\." equivalence)]
[number
- ["f" frac]
- ["." i64 ("#\." hash)]]]
+ ["f" frac]]]
[math
["." random]]]
{1
@@ -26,6 +26,8 @@
(`` ($_ _.and
(_.for [/.equivalence /.=]
($equivalence.spec /.equivalence random.nat))
+ (_.for [/.hash]
+ ($hash.spec /.hash random.nat))
(_.for [/.order /.<]
($order.spec /.order random.nat))
(_.for [/.enum]
@@ -119,11 +121,6 @@
[expected (\ ! map (/.% 1,000,000) random.nat)]
(_.cover [/.frac]
(|> expected /.frac f.nat (/.= expected))))
- (do random.monad
- [sample random.nat]
- (_.cover [/.hash]
- (i64\= (i64\hash sample)
- (\ /.hash hash sample))))
..predicate
..signature
diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux
index 2807dac8d..294d8b97a 100644
--- a/stdlib/source/test/lux/data/number/rev.lux
+++ b/stdlib/source/test/lux/data/number/rev.lux
@@ -6,6 +6,7 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." hash]
["$." order]
["$." enum]
["$." interval]
@@ -27,6 +28,8 @@
(`` ($_ _.and
(_.for [/.equivalence /.=]
($equivalence.spec /.equivalence random.rev))
+ (_.for [/.hash]
+ ($hash.spec /.hash random.rev))
(_.for [/.order /.<]
($order.spec /.order random.rev))
(_.for [/.enum]
@@ -156,11 +159,6 @@
random.safe-frac)]
(_.cover [/.frac]
(|> expected f.rev /.frac (f.= expected))))
- (do random.monad
- [sample random.rev]
- (_.cover [/.hash]
- (i64\= (i64\hash sample)
- (\ /.hash hash sample))))
..signature
))))
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index cd03b89fc..2dcd2bfa8 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -21,6 +21,7 @@
["." random]]]
["." / #_
["#." buffer]
+ ["#." encoding]
["#." regex]]
{1
["." /]})
@@ -297,5 +298,6 @@
(/.replace-all sep1 sep2 sample1))))
/buffer.test
+ /encoding.test
/regex.test
)))
diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux
new file mode 100644
index 000000000..fcf01e93d
--- /dev/null
+++ b/stdlib/source/test/lux/data/text/encoding.lux
@@ -0,0 +1,224 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ {[0 #spec]
+ [/
+ ["$." codec]]}]
+ [control
+ ["." try]]
+ [data
+ ["." maybe]
+ ["." text ("#\." equivalence)]
+ [number
+ ["n" nat]]
+ [collection
+ ["." list ("#\." functor)]
+ ["." set]]]
+ [macro
+ ["." template]]
+ [math
+ ["." random (#+ Random)]]]
+ {1
+ ["." /]})
+
+(with-expansions [<encodings> (as-is [all/a
+ [/.ascii]]
+
+ [all/ibm<1000
+ [/.ibm-37
+ /.ibm-273
+ /.ibm-277
+ /.ibm-278
+ /.ibm-280
+ /.ibm-284
+ /.ibm-285
+ /.ibm-290
+ /.ibm-297
+ /.ibm-300
+ /.ibm-420
+ /.ibm-424
+ /.ibm-437
+ /.ibm-500
+ /.ibm-737
+ /.ibm-775
+ /.ibm-833
+ /.ibm-834
+ /.ibm-838
+ /.ibm-850
+ /.ibm-852
+ /.ibm-855
+ /.ibm-856
+ /.ibm-857
+ /.ibm-858
+ /.ibm-860
+ /.ibm-861
+ /.ibm-862
+ /.ibm-863
+ /.ibm-864
+ /.ibm-865
+ /.ibm-866
+ /.ibm-868
+ /.ibm-869
+ /.ibm-870
+ /.ibm-871
+ /.ibm-874
+ /.ibm-875
+ /.ibm-918
+ /.ibm-921
+ /.ibm-922
+ /.ibm-930
+ /.ibm-933
+ /.ibm-935
+ /.ibm-937
+ /.ibm-939
+ /.ibm-942
+ /.ibm-942c
+ /.ibm-943
+ /.ibm-943c
+ /.ibm-948
+ /.ibm-949
+ /.ibm-949c
+ /.ibm-950
+ /.ibm-964
+ /.ibm-970]]
+
+ [all/ibm>1000
+ [/.ibm-1006
+ /.ibm-1025
+ /.ibm-1026
+ /.ibm-1046
+ /.ibm-1047
+ /.ibm-1097
+ /.ibm-1098
+ /.ibm-1112
+ /.ibm-1122
+ /.ibm-1123
+ /.ibm-1124
+ /.ibm-1140
+ /.ibm-1141
+ /.ibm-1142
+ /.ibm-1143
+ /.ibm-1144
+ /.ibm-1145
+ /.ibm-1146
+ /.ibm-1147
+ /.ibm-1148
+ /.ibm-1149
+ /.ibm-1166
+ /.ibm-1364
+ /.ibm-1381
+ /.ibm-1383
+ /.ibm-33722]]
+
+ [all/iso
+ [/.iso-2022-cn
+ /.iso2022-cn-cns
+ /.iso2022-cn-gb
+ /.iso-2022-jp
+ /.iso-2022-jp-2
+ /.iso-2022-kr
+ /.iso-8859-1
+ /.iso-8859-2
+ /.iso-8859-3
+ /.iso-8859-4
+ /.iso-8859-5
+ /.iso-8859-6
+ /.iso-8859-7
+ /.iso-8859-8
+ /.iso-8859-9
+ /.iso-8859-11
+ /.iso-8859-13
+ /.iso-8859-15]]
+
+ [all/mac
+ [/.mac-arabic
+ /.mac-central-europe
+ /.mac-croatian
+ /.mac-cyrillic
+ /.mac-dingbat
+ /.mac-greek
+ /.mac-hebrew
+ /.mac-iceland
+ /.mac-roman
+ /.mac-romania
+ /.mac-symbol
+ /.mac-thai
+ /.mac-turkish
+ /.mac-ukraine]]
+
+ [all/utf
+ [/.utf-8
+ /.utf-16
+ /.utf-32]]
+
+ [all/windows
+ [/.windows-31j
+ /.windows-874
+ /.windows-949
+ /.windows-950
+ /.windows-1250
+ /.windows-1252
+ /.windows-1251
+ /.windows-1253
+ /.windows-1254
+ /.windows-1255
+ /.windows-1256
+ /.windows-1257
+ /.windows-1258
+ /.windows-iso2022jp
+ /.windows-50220
+ /.windows-50221]]
+
+ [all/others
+ [/.cesu-8
+ /.koi8-r
+ /.koi8-u]]
+ )
+ <named> (template [<definition> <by-letter>]
+ [((: (-> Any (List /.Encoding))
+ (function (_ _)
+ (`` (list (~~ (template.splice <by-letter>))))))
+ 123)]
+
+ <encodings>)]
+ (def: all-encodings
+ (list.concat (list <named>)))
+
+ (def: unique-encodings
+ (set.from-list text.hash (list\map /.name ..all-encodings)))
+
+ (def: verdict
+ (n.= (list.size ..all-encodings)
+ (set.size ..unique-encodings)))
+
+ (template [<definition> <by-letter>]
+ [(def: <definition>
+ Test
+ (`` (_.cover [/.name (~~ (template.splice <by-letter>))]
+ ..verdict)))]
+
+ <encodings>)
+
+ (def: #export random
+ (Random /.Encoding)
+ (let [options (list.size ..all-encodings)]
+ (do {! random.monad}
+ [choice (\ ! map (n.% options) random.nat)]
+ (wrap (maybe.assume (list.nth choice ..all-encodings))))))
+
+ (def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Encoding])
+ (`` ($_ _.and
+ (_.for [/.utf8]
+ ($codec.spec text.equivalence /.utf8 (random.unicode 5)))
+
+ (~~ (template [<definition> <by-letter>]
+ [<definition>]
+
+ <encodings>))
+ ))))
+ )
diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux
index c1b8a4b5f..fb31baa0e 100644
--- a/stdlib/source/test/lux/locale/language.lux
+++ b/stdlib/source/test/lux/locale/language.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
["." /]})
@@ -34,7 +38,7 @@
{#count count
#names (|> languages (list\map /.name) (set.from-list text.hash))
#codes (|> languages (list\map /.code) (set.from-list text.hash))
- #languages (|> languages (set.from-list /.hash))
+ #languages (set.from-list /.hash languages)
#test (_.cover <languages>
true)}))]
@@ -256,11 +260,24 @@
(!aliases /.zaza [/.dimili /.dimli /.kirdki /.kirmanjki /.zazaki])
))
+(def: #export random
+ (Random /.Language)
+ (let [options (|> ..languages
+ (list\map (|>> (get@ #languages) 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 [/.Language])
($_ _.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
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
)))