@@ -20,6 +20,10 @@ evaluateTests =
2020 testGroup " DAP.Integration.Evaluate"
2121 [ testCase " Return structured representation for evaluated expressions (issue #116)"
2222 evaluateStructured
23+ , testCase " Imported module bindings available in evaluate context (issue #233)"
24+ evaluateImportedBindings
25+ , testCase " Imported module bindings available in repl context (issue #233)"
26+ replImportedBindings
2327 ]
2428
2529evaluateStructured :: Assertion
@@ -38,3 +42,45 @@ evaluateStructured =
3842 [] -> liftIO $ assertFailure $
3943 " No variable named 1 in evaluation result: " ++ show respChildren
4044 disconnect
45+
46+ -- | Test that bindings from imported modules are available when evaluating
47+ -- expressions at a breakpoint (issue #233).
48+ evaluateImportedBindings :: Assertion
49+ evaluateImportedBindings =
50+ withTestDAPServer " test/integration/T233" [] $ \ test_dir server ->
51+ withTestDAPServerClient server $ do
52+ let cfg = mkLaunchConfig test_dir " T233.hs"
53+ hitBreakpointWith cfg 14
54+
55+ -- sort is imported from Data.List
56+ sortResp <- evaluate " show (sort xs)"
57+ liftIO $ assertEqual " sort xs result" " \" [1,1,2,3,4,5,6,9]\" " (DAP. evaluateResponseResult sortResp)
58+
59+ -- nub is imported from Data.List
60+ nubResp <- evaluate " show (nub xs)"
61+ liftIO $ assertEqual " nub xs result" " \" [3,1,4,5,9,2,6]\" " (DAP. evaluateResponseResult nubResp)
62+
63+ -- Map is a qualified import
64+ mapResp <- evaluate " show (Map.lookup \" a\" m)"
65+ liftIO $ assertEqual " Map.lookup result" " \" Just 1\" " (DAP. evaluateResponseResult mapResp)
66+
67+ disconnect
68+
69+ -- | Test that bindings from imported modules are available in the REPL context
70+ -- at a breakpoint (issue #233).
71+ replImportedBindings :: Assertion
72+ replImportedBindings =
73+ withTestDAPServer " test/integration/T233" [] $ \ test_dir server ->
74+ withTestDAPServerClient server $ do
75+ let cfg = mkLaunchConfig test_dir " T233.hs"
76+ hitBreakpointWith cfg 14
77+
78+ -- sort is imported from Data.List
79+ sortResp <- evaluateWith (Just DAP. EvaluateArgumentsContextRepl ) " show (sort xs)"
80+ liftIO $ assertEqual " sort xs result (repl)" " \" [1,1,2,3,4,5,6,9]\" " (DAP. evaluateResponseResult sortResp)
81+
82+ -- Map is a qualified import
83+ mapResp <- evaluateWith (Just DAP. EvaluateArgumentsContextRepl ) " show (Map.lookup \" a\" m)"
84+ liftIO $ assertEqual " Map.lookup result (repl)" " \" Just 1\" " (DAP. evaluateResponseResult mapResp)
85+
86+ disconnect
0 commit comments