aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/math/random.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/math/random.lux')
-rw-r--r--stdlib/source/test/lux/math/random.lux49
1 files changed, 49 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/math/random.lux b/stdlib/source/test/lux/math/random.lux
new file mode 100644
index 000000000..acc161cc4
--- /dev/null
+++ b/stdlib/source/test/lux/math/random.lux
@@ -0,0 +1,49 @@
+(.module:
+ [lux #*
+ [control
+ [monad (#+ do Monad)]]
+ [data
+ ["." number]
+ [collection
+ ["." list]
+ ["." row]
+ ["." array]
+ ["." queue]
+ ["." stack]
+ ["." set]
+ ["dict" dictionary]]]
+ [math
+ ["r" random]]]
+ lux/test)
+
+(context: "Random."
+ (<| (times 100)
+ (do @
+ [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
+ _list (r.list size r.nat)
+ _row (r.row size r.nat)
+ _array (r.array size r.nat)
+ _queue (r.queue size r.nat)
+ _stack (r.stack size r.nat)
+ _set (r.set number.hash size r.nat)
+ _dict (r.dictionary number.hash size r.nat r.nat)
+ top r.nat
+ filtered (|> r.nat (r.filter (n/<= top)))]
+ ($_ seq
+ (test "Can produce lists."
+ (n/= size (list.size _list)))
+ (test "Can produce rows."
+ (n/= size (row.size _row)))
+ (test "Can produce arrays."
+ (n/= size (array.size _array)))
+ (test "Can produce queues."
+ (n/= size (queue.size _queue)))
+ (test "Can produce stacks."
+ (n/= size (stack.size _stack)))
+ (test "Can produce sets."
+ (n/= size (set.size _set)))
+ (test "Can produce dicts."
+ (n/= size (dict.size _dict)))
+ (test "Can filter values."
+ (n/<= top filtered))
+ ))))