summary refs log tree commit diff stats
path: root/tests/run/uclosures.nim
blob: d54b882858849a308f0f901c958e69ab3b933c27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
import unittest

test "loop variables are captured by copy":
  var funcs: seq[proc (): int {.closure.}] = @[]
  
  for i in 0..10:
    funcs.add do -> int: return i * i

  check funcs[0]() == 0
  check funcs[3]() == 9