diff options
author | Zahary Karadjov <zahary@gmail.com> | 2012-03-10 17:26:34 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2012-03-10 17:26:34 +0200 |
commit | f9876d379dab388e8ef706682a29dae9aeb9c40e (patch) | |
tree | e6c724a82afd4f3551f6feb9ab0033baa3c0ac9a /tests | |
parent | e88123fb17141ce6134411269c71bdbf8cba46d3 (diff) | |
download | Nim-f9876d379dab388e8ef706682a29dae9aeb9c40e.tar.gz |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/tunittests.nim | 2 | ||||
-rw-r--r-- | tests/run/uclosures.nim | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/run/tunittests.nim b/tests/run/tunittests.nim new file mode 100644 index 000000000..fa7fe5075 --- /dev/null +++ b/tests/run/tunittests.nim @@ -0,0 +1,2 @@ +import uclosures + diff --git a/tests/run/uclosures.nim b/tests/run/uclosures.nim new file mode 100644 index 000000000..d54b88285 --- /dev/null +++ b/tests/run/uclosures.nim @@ -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 + |