Skip to content

Commit e7d1e36

Browse files
committed
Interestingly, this test with the Other crashes HDB when setting the second breakpoint...
1 parent c95c806 commit e7d1e36

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

test/haskell/Test/Integration/Evaluate.hs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module Test.Integration.Evaluate (evaluateTests) where
55

66
import Control.Monad.IO.Class (liftIO)
7+
import Data.List (isInfixOf)
78
import Test.DAP
89
import Test.Tasty
910
import Test.Tasty.HUnit
@@ -42,24 +43,38 @@ evaluateStructured =
4243
disconnect
4344

4445
-- | Test that bindings from imported modules are available when evaluating
45-
-- expressions at a breakpoint (issue #233).
46+
-- expressions at a breakpoint (issue #233), and that they are NOT available
47+
-- when stopped in a different module that doesn't import them.
4648
evaluateImportedBindings :: Assertion
4749
evaluateImportedBindings =
4850
withTestDAPServer "test/integration/T233" [] $ \test_dir server ->
4951
withTestDAPServerClient server $ do
5052
let cfg = mkLaunchConfig test_dir "T233.hs"
51-
hitBreakpointWith cfg 14
5253

53-
-- sort is imported from Data.List
54+
_ <- sync $ launchWith cfg
55+
waitFiltering_ EventTy "initialized"
56+
-- T233.hs imports Data.Map.Strict as Map; Other.hs does not
57+
_ <- sync $ setLineBreakpoints test_dir "T233.hs" [15]
58+
_ <- sync $ setLineBreakpoints test_dir "Other.hs" [4] -- TODO: Crashes here!
59+
_ <- sync configurationDone
60+
_ <- assertStoppedLocation DAP.StoppedEventReasonBreakpoint 15
61+
62+
-- Stopped in T233.hs which imports Data.List and Data.Map.Strict as Map
5463
sortResp <- evaluate "show (sort xs)"
5564
liftIO $ assertEqual "sort xs result" "\"[1,1,2,3,4,5,6,9]\"" (DAP.evaluateResponseResult sortResp)
5665

57-
-- nub is imported from Data.List
58-
nubResp <- evaluate "show (nub xs)"
59-
liftIO $ assertEqual "nub xs result" "\"[3,1,4,5,9,2,6]\"" (DAP.evaluateResponseResult nubResp)
60-
61-
-- Map is a qualified import
6266
mapResp <- evaluate "show (Map.lookup \"a\" m)"
6367
liftIO $ assertEqual "Map.lookup result" "\"Just 1\"" (DAP.evaluateResponseResult mapResp)
6468

69+
-- Resume and stop at breakpoint in Other.hs, which does not import Map
70+
continueThread 0
71+
_ <- assertStoppedLocation DAP.StoppedEventReasonBreakpoint 4
72+
73+
-- Map is not imported in Other.hs; evaluating Map.fromList should fail
74+
mapFailResp <- evaluate "Map.fromList [(1,'a')]"
75+
let result = DAP.evaluateResponseResult mapFailResp
76+
liftIO $ assertBool
77+
("expected 'not in scope' error for Map.fromList, got: " ++ show result)
78+
("not in scope" `isInfixOf` show result)
79+
6580
disconnect

test/integration/T233/Other.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Other where
2+
3+
process :: [Int] -> IO ()
4+
process xs = do
5+
let n = length xs
6+
print n

test/integration/T233/T233.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ module Main where
22

33
import Data.List (sort, nub)
44
import qualified Data.Map.Strict as Map
5+
import Other (process)
56

67
main :: IO ()
78
main = do
89
let xs = [3, 1, 4, 1, 5, 9, 2, 6] :: [Int]
910
let m = Map.fromList [("a", 1), ("b", 2)] :: Map.Map String Int
1011
check xs m
12+
process xs
1113

1214
check :: [Int] -> Map.Map String Int -> IO ()
1315
check xs m = do

0 commit comments

Comments
 (0)