Skip to content

Commit

Permalink
Tighten up Stan plugin language extension test cases
Browse files Browse the repository at this point in the history
These changes ensure that the tests will fail given bad mappings in
either the `cabalExtensionsMap` OR the `checksMap`. Either of these
could cause bad behavior as seen in issue haskell#3174.
  • Loading branch information
keithfancher committed Jan 31, 2024
1 parent 802b46c commit c0dac2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/hls-stan-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ tests =
runStanSession "" $ do
doc <- openDoc "extension-tests/language-pragma/LanguagePragmaTest.hs" "haskell"
diags <- waitForDiagnosticsFromSource doc "stan"
liftIO $ length diags @?= 0
-- We must include at least one valid diagnostic in our test file to avoid
-- the false-positive case where Stan finds no analyses to perform due to a
-- bad mapping, which would also lead to zero diagnostics being returned.
liftIO $ length diags @?= 1
return ()
, testCase "respects language extensions defined in the .cabal file" $
runStanSession "" $ do
doc <- openDoc "extension-tests/cabal-file/CabalFileTest.hs" "haskell"
diags <- waitForDiagnosticsFromSource doc "stan"
liftIO $ length diags @?= 0
-- We need at least one valid diagnostic here too, for the same reason as above.
liftIO $ length diags @?= 1
return ()
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ module CabalFileTest () where

-- With `StrictData` enabled in the `.cabal` file, Stan shouldn't complain here:
data A = A Int Int

-- ...but it should still complain here!
kewlFunc = undefined
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ module LanguagePragmaTest () where

-- With the above `StrictData` language pragma, Stan shouldn't complain here:
data A = A Int Int

-- ...but it should still complain here!
kewlFunc = undefined

0 comments on commit c0dac2e

Please sign in to comment.