aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/codec.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/control/codec.lux')
-rw-r--r--stdlib/source/test/lux/control/codec.lux27
1 files changed, 27 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/control/codec.lux b/stdlib/source/test/lux/control/codec.lux
new file mode 100644
index 000000000..22c161616
--- /dev/null
+++ b/stdlib/source/test/lux/control/codec.lux
@@ -0,0 +1,27 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [control
+ [monad (#+ do)]]
+ [data
+ text/format
+ ["." error]]
+ [math
+ ["r" random (#+ Random)]]]
+ {1
+ ["." / (#+ Codec)
+ [//
+ [equivalence (#+ Equivalence)]]]})
+
+(def: #export (test (^open "/@.") (^open "/@.") generator)
+ (All [m a] (-> (Codec m a) (Equivalence a) (Random a) Test))
+ (do r.monad
+ [expected generator]
+ (<| (_.context (%name (name-of /.Codec)))
+ (_.test "Reflexivity."
+ (case (|> expected /@encode /@decode)
+ (#error.Success actual)
+ (/@= expected actual)
+
+ (#error.Failure error)
+ false)))))