Skip to content

Commit

Permalink
Fix file tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed May 10, 2022
1 parent f8bc989 commit 8bc810a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
19 changes: 11 additions & 8 deletions test/Tests/src/System/File_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,25 @@ spec =

Test.specify "should list files in a directory" <|
immediate = Enso_Project.data.list . map .to_text
immediate.sort.should_equal (resolve ["books.json", "sample.txt", "subdirectory", "windows.txt"])
immediate.sort.should_equal (resolve ["books.json", "sample.txt", "transient", "tree", "windows.txt"])

filtered1 = Enso_Project.data.list name_filter="s[a-cw]mple.{t?t,md}" . map .to_text
filtered1.should_equal (resolve ["sample.txt"])

filtered2 = File.list Enso_Project.data name_filter="*dir*" . map .to_text
filtered2.should_equal (resolve ["subdirectory"])
filtered2 = File.list Enso_Project.data name_filter="*re*" . map .to_text
filtered2.should_equal (resolve ["tree"])

Test.specify "should list files in a directory recursively" <|
all = Enso_Project.data.list recursive=True . map .to_text
all.sort.should_equal (resolve ["", "books.json", "sample.txt", "subdirectory", "subdirectory/a.txt", "subdirectory/nested", "subdirectory/nested/b.txt", "windows.txt"])
root = Enso_Project.data / "tree"
resolve files = files.map str-> (root / str) . to_text

filtered1 = Enso_Project.data.list name_filter="**.txt" recursive=True . map .to_text
filtered1.sort.should_equal (resolve ["sample.txt", "subdirectory/a.txt", "subdirectory/nested/b.txt", "windows.txt"])
all = root.list recursive=True . map .to_text
all.sort.should_equal (resolve ["", "sample.csv", "sample.txt", "subdirectory", "subdirectory/a.txt", "subdirectory/nested", "subdirectory/nested/b.txt"])

filtered2 = Enso_Project.data.list name_filter="*/*/*" recursive=True . map .to_text
filtered1 = root.list name_filter="**.txt" recursive=True . map .to_text
filtered1.sort.should_equal (resolve ["sample.txt", "subdirectory/a.txt", "subdirectory/nested/b.txt"])

filtered2 = root.list name_filter="*/*/*" recursive=True . map .to_text
filtered2.should_equal (resolve ["subdirectory/nested/b.txt"])

main = Test.Suite.run_main here.spec

0 comments on commit 8bc810a

Please sign in to comment.