summary refs log tree commit diff stats
path: root/tests/system/alloc.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-03-07 22:28:48 +0100
committerAraq <rumpf_a@web.de>2014-03-07 22:28:48 +0100
commitdd216755ff61901eb0b08c56965f58fcabdf4a0e (patch)
tree56bbf3b8586fcbd7e79cfc008db3b8e05e4c3e2a /tests/system/alloc.nim
parent91d842e1ec070a9ab7f883820bd6244526f5d622 (diff)
parent2cbe46daff73987d819ea0ca4bc6ada919d531d4 (diff)
downloadNim-dd216755ff61901eb0b08c56965f58fcabdf4a0e.tar.gz
Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
Diffstat (limited to 'tests/system/alloc.nim')
-rw-r--r--tests/system/alloc.nim45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/system/alloc.nim b/tests/system/alloc.nim
new file mode 100644
index 000000000..665b448ac
--- /dev/null
+++ b/tests/system/alloc.nim
@@ -0,0 +1,45 @@
+var x: ptr int
+
+x = cast[ptr int](alloc(7))
+assert x != nil
+
+x = alloc(int, 3)
+assert x != nil
+x.dealloc()
+
+x = alloc0(int, 4)
+assert cast[ptr array[4, int]](x)[0] == 0
+assert cast[ptr array[4, int]](x)[1] == 0
+assert cast[ptr array[4, int]](x)[2] == 0
+assert cast[ptr array[4, int]](x)[3] == 0
+
+x = cast[ptr int](x.realloc(2))
+assert x != nil
+
+x = x.reallocType(4)
+assert x != nil
+x.dealloc()
+
+x = cast[ptr int](allocShared(100))
+assert x != nil
+deallocShared(x)
+
+x = allocShared(int, 3)
+assert x != nil
+x.deallocShared()
+
+x = allocShared0(int, 3)
+assert x != nil
+assert cast[ptr array[3, int]](x)[0] == 0
+assert cast[ptr array[3, int]](x)[1] == 0
+assert cast[ptr array[3, int]](x)[2] == 0
+
+x = cast[ptr int](reallocShared(x, 2))
+assert x != nil
+
+x = reallocType(x, 12)
+assert x != nil
+
+x = reallocSharedType(x, 1)
+assert x != nil
+x.deallocShared()