summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci.debugger
diff options
context:
space:
mode:
authorRoland Senn <rsx@bluewin.ch>2020-04-02 14:58:12 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-22 23:11:51 -0400
commit48b8951e819e5d7d06ad7e168323de320d87bbd6 (patch)
tree872280292ebe4e25eb9dfb9325d01b747111cbdc /testsuite/tests/ghci.debugger
parent6c9fae2342f19ab3e6ac688825a3817b23bf1fcc (diff)
downloadhaskell-48b8951e819e5d7d06ad7e168323de320d87bbd6.tar.gz
Fix tab-completion for :break (#17989)
In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command.
Diffstat (limited to 'testsuite/tests/ghci.debugger')
-rw-r--r--testsuite/tests/ghci.debugger/scripts/T17989.script12
-rw-r--r--testsuite/tests/ghci.debugger/scripts/T17989.stdout20
-rw-r--r--testsuite/tests/ghci.debugger/scripts/T17989A.hs13
-rw-r--r--testsuite/tests/ghci.debugger/scripts/T17989B.hs13
-rw-r--r--testsuite/tests/ghci.debugger/scripts/T17989C.hs7
-rw-r--r--testsuite/tests/ghci.debugger/scripts/T17989M.hs6
-rw-r--r--testsuite/tests/ghci.debugger/scripts/all.T1
7 files changed, 72 insertions, 0 deletions
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989.script b/testsuite/tests/ghci.debugger/scripts/T17989.script
new file mode 100644
index 0000000000..86f3f70e93
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T17989.script
@@ -0,0 +1,12 @@
+:l T17989M
+:complete repl ":break "
+-- all listed names are really breakpoints
+:break B.bar
+:break B.foo
+:break T17989A.bar
+:break T17989A.foo
+:break T17989C.foo
+:break foo
+:break main
+:complete repl ":break B."
+:complete repl ":break f"
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989.stdout b/testsuite/tests/ghci.debugger/scripts/T17989.stdout
new file mode 100644
index 0000000000..ce658ace22
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T17989.stdout
@@ -0,0 +1,20 @@
+7 7 ":break "
+"B.bar"
+"B.foo"
+"T17989A.bar"
+"T17989A.foo"
+"T17989C.foo"
+"foo"
+"main"
+Breakpoint 0 activated at T17989B.hs:10:9-25
+Breakpoint 1 activated at T17989B.hs:7:6-11
+Breakpoint 2 activated at T17989A.hs:10:7-13
+Breakpoint 3 activated at T17989A.hs:4:9-14
+Breakpoint 4 activated at T17989C.hs:4:9-26
+Breakpoint 4 was already set at T17989C.hs:4:9-26
+Breakpoint 5 activated at T17989M.hs:6:8-51
+2 2 ":break "
+"B.bar"
+"B.foo"
+1 1 ":break "
+"foo"
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989A.hs b/testsuite/tests/ghci.debugger/scripts/T17989A.hs
new file mode 100644
index 0000000000..32dfef5e85
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T17989A.hs
@@ -0,0 +1,13 @@
+module T17989A (foo, bar) where
+
+foo :: Int -> String
+foo n = x <> y
+ where
+ x = "A.foo-"
+ y = priv n
+
+bar :: String
+bar = "A.bar"
+
+priv :: Int -> String
+priv n = "A.foo-" <> show n
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989B.hs b/testsuite/tests/ghci.debugger/scripts/T17989B.hs
new file mode 100644
index 0000000000..e48067f936
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T17989B.hs
@@ -0,0 +1,13 @@
+module T17989B (foo, bar) where
+
+foo :: Int -> String
+foo n =
+ let x = "B.foo-"
+ y = priv n
+ in x <> y
+
+bar :: Int -> String
+bar n = "B.bar" <> show n
+
+priv :: Int -> String
+priv n = "B.foo-" <> show n
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989C.hs b/testsuite/tests/ghci.debugger/scripts/T17989C.hs
new file mode 100644
index 0000000000..c53471e14d
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T17989C.hs
@@ -0,0 +1,7 @@
+module T17989C (foo) where
+
+foo :: Int -> String
+foo n = "C.foo-" <> priv n
+
+priv :: Int -> String
+priv n = "C.foo-" <> show n
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989M.hs b/testsuite/tests/ghci.debugger/scripts/T17989M.hs
new file mode 100644
index 0000000000..c6d77072c2
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T17989M.hs
@@ -0,0 +1,6 @@
+import qualified T17989A
+import qualified T17989B as B
+import T17989C
+
+main :: IO ()
+main = putStrLn (T17989A.foo 3 <> B.foo 5 <> foo 7)
diff --git a/testsuite/tests/ghci.debugger/scripts/all.T b/testsuite/tests/ghci.debugger/scripts/all.T
index db597a455f..12fe420363 100644
--- a/testsuite/tests/ghci.debugger/scripts/all.T
+++ b/testsuite/tests/ghci.debugger/scripts/all.T
@@ -125,3 +125,4 @@ test('T16700', normal, ghci_script, ['T16700.script'])
test('break029', extra_files(['break029.hs']), ghci_script, ['break029.script'])
test('T2215', normal, ghci_script, ['T2215.script'])
+test('T17989', normal, ghci_script, ['T17989.script'])