aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.cp/cpcompletion.exp42
-rw-r--r--gdb/testsuite/gdb.cp/pr9594.cc13
-rw-r--r--gdb/testsuite/lib/completion-support.exp2
4 files changed, 65 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c4d8ecf..450ca35 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2017-12-13 Pedro Alves <palves@redhat.com>
+
+ * gdb.cp/cpcompletion.exp: Load completion-support.exp.
+ ("expression with namespace"): New set of tests.
+ * gdb.cp/pr9594.cc (Test_NS::foo, Test_NS::bar)
+ (Nested::Test_NS::qux): New.
+ * lib/completion-support.exp (test_gdb_complete_cmd_multiple): Add
+ defaults to 'start_quote_char' and 'end_quote_char' parameters.
+
2017-12-13 Joel Brobecker <brobecker@adacore.com>
* gdb.base/server-del-break.c: New file.
diff --git a/gdb/testsuite/gdb.cp/cpcompletion.exp b/gdb/testsuite/gdb.cp/cpcompletion.exp
index c7883ee..62669dc 100644
--- a/gdb/testsuite/gdb.cp/cpcompletion.exp
+++ b/gdb/testsuite/gdb.cp/cpcompletion.exp
@@ -15,6 +15,8 @@
# This file is part of the gdb testsuite.
+load_lib completion-support.exp
+
# A helper procedure to test location completions restricted by
# class.
proc test_class_complete {class expr name matches} {
@@ -85,3 +87,43 @@ gdb_test "complete p foo1.Fo" "p foo1\\.Foofoo"
# Test completion with an anonymous struct.
gdb_test "complete p a.g" "p a\\.get"
+
+with_test_prefix "expression with namespace" {
+ # Before the scope operator, GDB shows all the symbols whose
+ # fully-qualified name matches the completion word.
+ test_gdb_complete_multiple "p " "Test_NS" "" {
+ "Test_NS"
+ "Test_NS::Nested"
+ "Test_NS::Nested::qux"
+ "Test_NS::bar"
+ "Test_NS::foo"
+ }
+
+ # Unlike in linespecs, tab- and complete-command completion work a
+ # bit differently when completing around the scope operator. The
+ # matches in the tab-completion case only show the part of the
+ # symbol after the scope, since ':' is a word break character.
+
+ set tab_completion_list {
+ "Nested"
+ "Nested::qux"
+ "bar"
+ "foo"
+ }
+ test_gdb_complete_tab_multiple "p Test_NS:" ":" $tab_completion_list
+ test_gdb_complete_tab_multiple "p Test_NS::" "" $tab_completion_list
+
+ # OTOH, the complete command must show the whole command, with
+ # qualified symbol displayed as entered by the user.
+ set cmd_completion_list {
+ "Test_NS::Nested"
+ "Test_NS::Nested::qux"
+ "Test_NS::bar"
+ "Test_NS::foo"
+ }
+ test_gdb_complete_cmd_multiple "p " "Test_NS:" $cmd_completion_list
+ test_gdb_complete_cmd_multiple "p " "Test_NS::" $cmd_completion_list
+
+ # Add a disambiguating character and we get a unique completion.
+ test_gdb_complete_unique "p Test_NS::f" "p Test_NS::foo"
+}
diff --git a/gdb/testsuite/gdb.cp/pr9594.cc b/gdb/testsuite/gdb.cp/pr9594.cc
index 8fdee84..54ddaaf 100644
--- a/gdb/testsuite/gdb.cp/pr9594.cc
+++ b/gdb/testsuite/gdb.cp/pr9594.cc
@@ -39,6 +39,19 @@ void Foo::Foofoo ()
{
}
+namespace Test_NS {
+
+int foo;
+int bar;
+
+namespace Nested {
+
+int qux;
+
+} /* namespace Nested */
+
+} /* namespace Test_NS */
+
int main ()
{
// Anonymous struct with method.
diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp
index c7cc1c9..fe5b16a 100644
--- a/gdb/testsuite/lib/completion-support.exp
+++ b/gdb/testsuite/lib/completion-support.exp
@@ -178,7 +178,7 @@ proc test_gdb_complete_cmd_unique { input_line complete_line_re } {
# complete command displays the COMPLETION_LIST completion list. Each
# entry in the list should be prefixed by CMD_PREFIX.
-proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list start_quote_char end_quote_char } {
+proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list {start_quote_char ""} {end_quote_char ""} } {
global gdb_prompt
set expected_re [make_cmd_completion_list_re $cmd_prefix $completion_list $start_quote_char $end_quote_char]