diff options
author | Yuriy Glukhov <yutiy.glukhov@gmail.com> | 2016-06-28 13:13:37 +0300 |
---|---|---|
committer | Yuriy Glukhov <yutiy.glukhov@gmail.com> | 2016-06-28 13:15:02 +0300 |
commit | e61cfea78b9ebb8df734c7b9d15d81b50ce76613 (patch) | |
tree | 703c93826480a5b9f1b3420b684da5d1701865d0 /tests/closure | |
parent | ecfcf49a9d57c40f32eb019368b32828b86a041b (diff) | |
download | Nim-e61cfea78b9ebb8df734c7b9d15d81b50ce76613.tar.gz |
Fixed broken test. Added closureScope test.
Diffstat (limited to 'tests/closure')
-rw-r--r-- | tests/closure/uclosures.nim | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/closure/uclosures.nim b/tests/closure/uclosures.nim index 817bfec6b..f259cfeb9 100644 --- a/tests/closure/uclosures.nim +++ b/tests/closure/uclosures.nim @@ -1,12 +1,23 @@ +# This test is included from within tunittests import unittest -test "loop variables are captured by copy": +test "loop variables are captured by ref": var funcs: seq[proc (): int {.closure.}] = @[] for i in 0..10: let ii = i funcs.add do -> int: return ii * ii + check funcs[0]() == 100 + check funcs[3]() == 100 + +test "loop variables in closureScope are captured by copy": + var funcs: seq[proc (): int {.closure.}] = @[] + + for i in 0..10: + closureScope: + let ii = i + funcs.add do -> int: return ii * ii + check funcs[0]() == 0 check funcs[3]() == 9 - |