Token matches can occur at the beginning or end of a file

This commit is contained in:
Joshua Clayton 2016-05-22 07:03:37 -04:00
parent b7aefe66d0
commit 697f8b4135
2 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ import Unused.Regex
commandLineOptions :: String -> [String]
commandLineOptions t =
case regexSafeTerm t of
True -> ["\\W" ++ t ++ "\\W", ".", "-c", "--ackmate"]
True -> ["(\\W|^)" ++ t ++ "(\\W|$)", ".", "-c", "--ackmate"]
False -> [t, ".", "-c", "-Q", "--ackmate"]
regexSafeTerm :: String -> Bool

View File

@ -19,4 +19,4 @@ spec = parallel $
commandLineOptions "window.globalOverride" `shouldBe` ["window.globalOverride", ".", "-c", "-Q", "--ackmate"]
it "uses regular expression match with surrounding non-word matches for accuracy" $
commandLineOptions "awesome_method" `shouldBe` ["\\Wawesome_method\\W", ".", "-c", "--ackmate"]
commandLineOptions "awesome_method" `shouldBe` ["(\\W|^)awesome_method(\\W|$)", ".", "-c", "--ackmate"]