diff options
author | Araq <rumpf_a@web.de> | 2018-10-18 17:06:04 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-10-18 17:06:04 +0200 |
commit | 68c6d709d36beafd3bf44c15de399adb9c4f79fe (patch) | |
tree | 693fcf543933f2f1c19667066ca96a8b1c12e5fc /tests/iter | |
parent | 4644484fb73feed9fd314e7798436bd17456f937 (diff) | |
download | Nim-68c6d709d36beafd3bf44c15de399adb9c4f79fe.tar.gz |
fixes #5519
Diffstat (limited to 'tests/iter')
-rw-r--r-- | tests/iter/tclosureiters.nim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/iter/tclosureiters.nim b/tests/iter/tclosureiters.nim index 9eb27bb93..345a4867a 100644 --- a/tests/iter/tclosureiters.nim +++ b/tests/iter/tclosureiters.nim @@ -103,3 +103,39 @@ proc unusedB = var count = 0 for line in lineIter2("temp10.nim"): count += 1 + +# bug #5519 +import os, algorithm + +iterator filesIt(path: string): auto {.closure.} = + var files = newSeq[string]() + var dirs = newSeq[string]() + for k, p in os.walkDir(path): + let (_, n, e) = p.splitFile + if e != "": + continue + case k + of pcFile, pcLinkToFile: + files.add(n) + else: + dirs.add(n) + files.sort(system.cmp) + dirs.sort(system.cmp) + for f in files: + yield f + + for d in dirs: + files = newSeq[string]() + for k, p in os.walkDir(path / d): + let (_, n, e) = p.splitFile + if e != "": + continue + case k + of pcFile, pcLinkToFile: + files.add(n) + else: + discard + files.sort(system.cmp) + let prefix = path.splitPath[1] + for f in files: + yield prefix / f |