diff options
Diffstat (limited to 'tests/iter/tclosureiters.nim')
-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 |