Skip to content

Simplify FuzzySearch test (avoid dependency on /usr/share/dict/words) #4531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use quickcheck === to get more informative errors
  • Loading branch information
jhrcek committed Mar 31, 2025
commit ebee93c0abdc427d76b0c5c8c08ef2f5d2961796
6 changes: 3 additions & 3 deletions ghcide-test/exe/FuzzySearch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tests =
]
]

test :: Text -> Bool
test :: Text -> Property
test candidate = do
let previous =
catMaybes
Expand All @@ -38,7 +38,7 @@ test candidate = do
| d <- dictionary
]
new = catMaybes [(d,) <$> match candidate d | d <- dictionary]
previous == new
previous === new

propLegit :: Property
propLegit = forAll (elements dictionary) test
Expand Down Expand Up @@ -91,7 +91,7 @@ referenceImplementation :: forall s t.
referenceImplementation pat' t pre post extract =
if null pat then Just (Fuzzy t result totalScore) else Nothing
where
null :: (T.TextualMonoid s) => s -> Bool
null :: s -> Bool
null = not . T.any (const True)

s = extract t
Expand Down