summaryrefslogtreecommitdiff
path: root/lib/std/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2017-12-29 12:25:18 -0800
committerOri Bernstein <ori@markovcorp.com>2017-12-29 12:25:18 -0800
commitb4252aeded2d15592fe940e20f533f113000c61d (patch)
tree53db4601cb1e9e413f547a3d587d30ae150954a0 /lib/std/test
parent86f488a953c6830c6f39203aac8be34a338e1d44 (diff)
downloadmc-b4252aeded2d15592fe940e20f533f113000c61d.tar.gz
Add some tests to lib/std/alloc.myr
Diffstat (limited to 'lib/std/test')
-rw-r--r--lib/std/test/alloc.myr38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/std/test/alloc.myr b/lib/std/test/alloc.myr
new file mode 100644
index 0000000..76a6665
--- /dev/null
+++ b/lib/std/test/alloc.myr
@@ -0,0 +1,38 @@
+use std
+
+const main = {
+ var seed : uint32 = 0xe96d7f9c /* (std.now() : uint32) */
+ std.put("seed = 0x{x}\n", seed)
+
+ var r : std.rng# = std.mksrng(seed)
+
+ var m : byte[:][:][:] = std.slalloc(std.rngrand(r, 1, 20))
+ for var j = 0; j < m.len; ++j
+ m[j] = [][:]
+ ;;
+
+ var s : byte[:][:] = std.slalloc(std.rngrand(r, 1, 20))
+ for var j = 0; j < s.len; ++j
+ s[j] = std.slalloc(std.rngrand(r, 2, 34))
+ std.slfill(s[j], ('_' : byte))
+ ;;
+
+ for var i = 0; i < 10_000; i++
+ if std.rngrand(r, 0, 2) == 0
+ var j = std.rngrand(r, 0, m.len)
+ var k = std.rngrand(r, 0, s.len)
+
+ var num_s = std.rngrand(r, 50, 100)
+ for var l = 0; l < num_s; ++l
+ std.slpush(&m[j], std.sldup(s[k]))
+ ;;
+ else
+ var j = std.rngrand(r, 0, m.len)
+ for q : m[j]
+ std.slfree(q)
+ ;;
+ std.slfree(m[j])
+ m[j] = [][:]
+ ;;
+ ;;
+}