diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2014-03-31 15:49:04 -0500 |
---|---|---|
committer | Simon Hafner <hafnersimon@gmail.com> | 2014-03-31 15:49:04 -0500 |
commit | ffb36db5a6caa147119aed1728c8042dfa68a3e8 (patch) | |
tree | 0db6e9c9b39a21511cf6d5a1c2f489e35a10ed60 /tests/system | |
parent | 565031f0cd4768962fb19ac4e17efb994dfb4735 (diff) | |
parent | 44ee8aecfd70d1d381b5eed5ae52b01fae04452b (diff) | |
download | Nim-ffb36db5a6caa147119aed1728c8042dfa68a3e8.tar.gz |
Merge branch 'devel' of github.com:Araq/Nimrod into seq_toString
Diffstat (limited to 'tests/system')
-rw-r--r-- | tests/system/alloc.nim | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/system/alloc.nim b/tests/system/alloc.nim new file mode 100644 index 000000000..7abefec2a --- /dev/null +++ b/tests/system/alloc.nim @@ -0,0 +1,52 @@ +var x: ptr int + +x = cast[ptr int](alloc(7)) +assert x != nil +x = cast[ptr int](x.realloc(2)) +assert x != nil +x.dealloc() + +x = createU(int, 3) +assert x != nil +x.free() + +x = create(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 = x.resize(4) +assert x != nil +x.free() + +x = cast[ptr int](allocShared(100)) +assert x != nil +deallocShared(x) + +x = createSharedU(int, 3) +assert x != nil +x.freeShared() + +x = createShared(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 + +assert x != nil +x = cast[ptr int](x.resizeShared(2)) +assert x != nil +x.freeShared() + +x = create(int, 10) +assert x != nil +x = x.resize(12) +assert x != nil +x.dealloc() + +x = createShared(int, 1) +assert x != nil +x = x.resizeShared(1) +assert x != nil +x.freeShared() |