|
4 | 4 | module Test.Integration.Evaluate (evaluateTests) where |
5 | 5 |
|
6 | 6 | import Control.Monad.IO.Class (liftIO) |
| 7 | +import Data.List (isInfixOf) |
7 | 8 | import Test.DAP |
8 | 9 | import Test.Tasty |
9 | 10 | import Test.Tasty.HUnit |
@@ -42,24 +43,38 @@ evaluateStructured = |
42 | 43 | disconnect |
43 | 44 |
|
44 | 45 | -- | 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. |
46 | 48 | evaluateImportedBindings :: Assertion |
47 | 49 | evaluateImportedBindings = |
48 | 50 | withTestDAPServer "test/integration/T233" [] $ \test_dir server -> |
49 | 51 | withTestDAPServerClient server $ do |
50 | 52 | let cfg = mkLaunchConfig test_dir "T233.hs" |
51 | | - hitBreakpointWith cfg 14 |
52 | 53 |
|
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 |
54 | 63 | sortResp <- evaluate "show (sort xs)" |
55 | 64 | liftIO $ assertEqual "sort xs result" "\"[1,1,2,3,4,5,6,9]\"" (DAP.evaluateResponseResult sortResp) |
56 | 65 |
|
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 |
62 | 66 | mapResp <- evaluate "show (Map.lookup \"a\" m)" |
63 | 67 | liftIO $ assertEqual "Map.lookup result" "\"Just 1\"" (DAP.evaluateResponseResult mapResp) |
64 | 68 |
|
| 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 | + |
65 | 80 | disconnect |
0 commit comments