mirror of
https://github.com/status-im/nim-ranges.git
synced 2025-01-12 13:54:14 +00:00
add proper test for proof of stack allocation (#23)
This commit is contained in:
parent
179c03822a
commit
4e6835d041
@ -34,3 +34,14 @@ suite "Stack arrays":
|
||||
expect RangeError:
|
||||
arr[3] = "another test"
|
||||
|
||||
test "proof of stack allocation":
|
||||
proc fun() =
|
||||
# NOTE: has to be inside a proc otherwise x1 not allocated on stack.
|
||||
var x1 = 0
|
||||
var arr = allocStackArray(int, 3)
|
||||
|
||||
check:
|
||||
# stack can go either up or down, hence `abs`.
|
||||
# 1024 should be large enough (was 312 on OSX).
|
||||
abs(cast[int](x1.addr) - cast[int](addr(arr[0]))) < 1024
|
||||
fun()
|
||||
|
Loading…
x
Reference in New Issue
Block a user