Skip to content

Commit

Permalink
Add specs for File.match? (#15348)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored Jan 17, 2025
1 parent 7135b1d commit 811cb79
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/std/file_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,11 @@ describe "File" do
assert_file_matches "a*", "abc"
assert_file_matches "a*/b", "abc/b"
assert_file_matches "*x", "xxx"
assert_file_matches "*.x", "a.x"
assert_file_matches "a/b/*.x", "a/b/c.x"
refute_file_matches "*.x", "a/b/c.x"
refute_file_matches "c.x", "a/b/c.x"
refute_file_matches "b/*.x", "a/b/c.x"
end

it "matches multiple expansions" do
Expand All @@ -1719,6 +1724,21 @@ describe "File" do
refute_file_matches "a*b*c*d*e*/f", "axbxcxdxexxx/fff"
end

it "**" do
assert_file_matches "a/b/**", "a/b/c.x"
assert_file_matches "a/**", "a/b/c.x"
assert_file_matches "a/**/d.x", "a/b/c/d.x"
refute_file_matches "a/**b/d.x", "a/bb/c/d.x"
refute_file_matches "a/b**/*", "a/bb/c/d.x"
end

it "** bugs (#15319)" do
refute_file_matches "a/**/*", "a/b/c/d.x"
assert_file_matches "a/b**/d.x", "a/bb/c/d.x"
refute_file_matches "**/*.x", "a/b/c.x"
assert_file_matches "**.x", "a/b/c.x"
end

it "** matches path separator" do
assert_file_matches "a**", "ab/c"
assert_file_matches "a**/b", "a/c/b"
Expand Down

0 comments on commit 811cb79

Please sign in to comment.