summaryrefslogtreecommitdiff
path: root/lib/std/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2018-01-26 18:14:27 -0800
committerOri Bernstein <ori@markovcorp.com>2018-01-26 18:14:27 -0800
commit24a566ff1751b246c8b6efd8adea3447975b9efa (patch)
treeb535f619dfc91f50622643f121fb0283fac8eac5 /lib/std/test
parent83bca2aaa7635be1ef17fdd5e3b02348b79f7dcc (diff)
downloadmc-24a566ff1751b246c8b6efd8adea3447975b9efa.tar.gz
Improve our env code, add tests.
It was fragile.
Diffstat (limited to 'lib/std/test')
-rw-r--r--lib/std/test/env.myr38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/std/test/env.myr b/lib/std/test/env.myr
new file mode 100644
index 0000000..31b3b2d
--- /dev/null
+++ b/lib/std/test/env.myr
@@ -0,0 +1,38 @@
+use std
+use testr
+
+const main = {
+ var e, v
+
+ /* set */
+ for var i = 0; i < 100; i++
+ e = std.fmt("ENV{}", i)
+ v = std.fmt("VAL{}", i)
+ std.setenv(e, v)
+ std.slfree(e)
+ std.slfree(v)
+ ;;
+
+ for var i = 0; i < 100; i++
+ e = std.fmt("ENV{}", i)
+ v = std.fmt("VAL{}", i)
+ std.assert(std.eq(std.getenvv(e, v), v), "get of {} failed", e)
+ std.slfree(e)
+ std.slfree(v)
+ ;;
+
+ for var i = 0; i < 100; i++
+ e = std.fmt("ENV{}", i)
+ v = std.fmt("VAL{}", 100-i)
+ std.setenv(e, v)
+ std.slfree(e)
+ std.slfree(v)
+ ;;
+ for var i = 0; i < 100; i++
+ e = std.fmt("ENV{}", i)
+ v = std.fmt("VAL{}", 100-i)
+ std.assert(std.eq(std.getenvv(e, v), v), "get of {} failed", e)
+ std.slfree(e)
+ std.slfree(v)
+ ;;
+}