Nim/tests/closure/tclosure3.nim
Andreas Rumpf c57e320c94
fixes 7833 (#8533)
* fixes #7833; still to-do: fix setLen
* make tests green again
* also fixes setLen and string concats; refs #7833
* change formating to avoid a compiler warning
* emit the write barrier also for addChar
* fixes yet another regression
* make setLengthStr compile for the old version
* make growobjcrash complete earlier
2018-08-05 11:42:38 +02:00

21 lines
450 B
Nim

discard """
file: "tclosure3.nim"
output: "success"
"""
proc main =
const n = 30
for iterations in 0..50_000:
var s: seq[proc(): string {.closure.}] = @[]
for i in 0 .. n-1:
(proc () =
let ii = i
s.add(proc(): string = return $(ii*ii)))()
for i in 0 .. n-1:
let val = s[i]()
if val != $(i*i): echo "bug ", val
if getOccupiedMem() > 5000_000: quit("still a leak!")
echo "success"
main()