Files
Nim/tests/run/uclosures.nim
Zahary Karadjov f9876d379d unit test for #100
unittest: the check macro will print only the non-literal part of the checked expression
tests/run: added tunittests.nim as a single central executable where unittests could be added for quicker compilation/execution of the test suite
2012-03-10 17:26:34 +02:00

12 lines
219 B
Nim

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