Archived
1
0
Fork 0

Fixed stack transfert sizing bug

This commit is contained in:
Julien Dessaux 2021-11-11 21:49:53 +01:00
parent 9321586129
commit 98fe417488
2 changed files with 4 additions and 4 deletions

View file

@ -62,7 +62,7 @@ func Transfert*(toss: var Stack, soss: var Stack, n: int) =
## (aka begin) and '}' (aka end) stackstack commands
toss.height += n
if toss.height > toss.size:
toss.size += 32
toss.size = toss.height
toss.data.setlen(toss.size)
for i in 1..min(soss.height, n):
toss.data[toss.height-i] = soss.data[soss.height-i]

View file

@ -101,8 +101,8 @@ suite "Stack":
check some.data[2] == -4
check some.data[3] == 0
test "Transfert":
var empty = NewStack()
var empty2 = NewStack()
var empty = NewStack(size=12)
var empty2 = NewStack(size=7)
empty[].Transfert(empty2[], 4)
check empty.height == 4
check empty2.height == 0
@ -111,7 +111,7 @@ suite "Stack":
check empty.data[2] == 0
check empty.data[3] == 0
empty[].Transfert(empty2[], 32)
check empty.size == 64
check empty.size == 36
empty = NewStack()
var some = NewStack()
some[].Push(2)