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:
parent
e88123fb17
commit
f9876d379d
4 changed files with 26 additions and 5 deletions
2
tests/run/tunittests.nim
Normal file
2
tests/run/tunittests.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import uclosures
|
||||
|
||||
11
tests/run/uclosures.nim
Normal file
11
tests/run/uclosures.nim
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue