aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/data')
-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
10 files changed, 248 insertions, 31 deletions
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>))
+ ))))
+ )