2003-04-23 David Carlton <carlton@bactrian.org>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / maint.exp
1 # Copyright 2003 Free Software Foundation Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20
21 # This file tests C++-specific maintenance commands and help on those.
22
23 # Currently, no source file is used.
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 # Test the help messages.
30
31 proc test_help {} {
32 gdb_test "help maintenance cplus" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
33
34 gdb_test "help maint cp" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
35
36 gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
37
38 gdb_test "help maint cp first_component" "Print the first class/namespace component of NAME."
39 }
40
41 # This is used when NAME should contain only a single component. Be
42 # careful to make sure that parentheses get escaped properly.
43 proc test_single_component {name} {
44 set matchname [string_to_regexp "$name"]
45 gdb_test "maint cp first_component $name" "$matchname"
46 }
47
48 proc test_first_component {} {
49 test_single_component "foo"
50 test_single_component "operator<<"
51 test_single_component "operator>>"
52 test_single_component "operator ->"
53 test_single_component "operator()"
54 test_single_component "operator>"
55 test_single_component "operator<"
56 test_single_component "operator ->"
57 test_single_component "operator ->"
58
59 test_single_component "foo()"
60 test_single_component "foo(int)"
61 test_single_component "foo(X::Y)"
62 test_single_component "foo(X::Y, A::B)"
63 test_single_component "foo(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)"
64 test_single_component "operator>(X::Y)"
65
66 # Operator names can show up in weird places.
67
68 test_single_component "int operator<< <char>()"
69 test_single_component "T<Cooperator>"
70
71 # NOTE: carlton/2003-04-23: I've only seen the first of these
72 # produced by the demangler, but I'm including two more just to be
73 # on the safe side.
74 test_single_component "int foo<&(operator<<(C, C))>()"
75 test_single_component "int foo<&operator<<(C, C)>()"
76 test_single_component "int foo<operator<<(C, C)>()"
77
78 gdb_test "maint cp first_component foo::bar" "foo"
79 gdb_test "maint cp first_component foo::bar::baz" "foo"
80 gdb_test "maint cp first_component C<A>::bar" "C<A>"
81 gdb_test "maint cp first_component C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >::bar" "C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >"
82 }
83
84 gdb_exit
85 gdb_start
86
87 test_help
88 test_first_component
89
90 gdb_exit
91 return 0
This page took 0.041243 seconds and 4 git commands to generate.