Skip to content

Commit c0dac2e

Browse files
committed
Tighten up Stan plugin language extension test cases
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 #3174.
1 parent 802b46c commit c0dac2e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

plugins/hls-stan-plugin/test/Main.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ tests =
4444
runStanSession "" $ do
4545
doc <- openDoc "extension-tests/language-pragma/LanguagePragmaTest.hs" "haskell"
4646
diags <- waitForDiagnosticsFromSource doc "stan"
47-
liftIO $ length diags @?= 0
47+
-- We must include at least one valid diagnostic in our test file to avoid
48+
-- the false-positive case where Stan finds no analyses to perform due to a
49+
-- bad mapping, which would also lead to zero diagnostics being returned.
50+
liftIO $ length diags @?= 1
4851
return ()
4952
, testCase "respects language extensions defined in the .cabal file" $
5053
runStanSession "" $ do
5154
doc <- openDoc "extension-tests/cabal-file/CabalFileTest.hs" "haskell"
5255
diags <- waitForDiagnosticsFromSource doc "stan"
53-
liftIO $ length diags @?= 0
56+
-- We need at least one valid diagnostic here too, for the same reason as above.
57+
liftIO $ length diags @?= 1
5458
return ()
5559
]
5660

plugins/hls-stan-plugin/test/testdata/extension-tests/cabal-file/CabalFileTest.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ module CabalFileTest () where
22

33
-- With `StrictData` enabled in the `.cabal` file, Stan shouldn't complain here:
44
data A = A Int Int
5+
6+
-- ...but it should still complain here!
7+
kewlFunc = undefined

plugins/hls-stan-plugin/test/testdata/extension-tests/language-pragma/LanguagePragmaTest.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ module LanguagePragmaTest () where
44

55
-- With the above `StrictData` language pragma, Stan shouldn't complain here:
66
data A = A Int Int
7+
8+
-- ...but it should still complain here!
9+
kewlFunc = undefined

0 commit comments

Comments
 (0)