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
This commit is contained in:
Zahary Karadjov 2012-03-10 17:26:34 +02:00
commit f9876d379d
4 changed files with 26 additions and 5 deletions

2
tests/run/tunittests.nim Normal file
View file

@ -0,0 +1,2 @@
import uclosures

11
tests/run/uclosures.nim Normal file
View file

@ -0,0 +1,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