1 |
24 |
jeremybenn |
# This testcase is part of GDB, the GNU debugger.
|
2 |
|
|
# Copyright 1993, 1997, 2004, 2007, 2008 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
# This program is free software; you can redistribute it and/or modify
|
5 |
|
|
# it under the terms of the GNU General Public License as published by
|
6 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
7 |
|
|
# (at your option) any later version.
|
8 |
|
|
#
|
9 |
|
|
# This program is distributed in the hope that it will be useful,
|
10 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
# GNU General Public License for more details.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program. If not, see .
|
16 |
|
|
|
17 |
|
|
# This file was written by Fred Fish. (fnf@cygnus.com)
|
18 |
|
|
# And rewritten by Michael Chastain (mec.gnu@mindspring.com)
|
19 |
|
|
|
20 |
|
|
if $tracelevel then {
|
21 |
|
|
strace $tracelevel
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
set prms_id 0
|
25 |
|
|
set bug_id 0
|
26 |
|
|
|
27 |
|
|
# Start with a fresh gdb.
|
28 |
|
|
|
29 |
|
|
gdb_exit
|
30 |
|
|
gdb_start
|
31 |
|
|
|
32 |
|
|
# Test input radices.
|
33 |
|
|
|
34 |
|
|
proc test_one_input { iradix input output } {
|
35 |
|
|
gdb_test "print $input" "$output" \
|
36 |
|
|
"print $input; expect $output; input radix $iradix"
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
proc test_input_radix { iradix iradixhex iradixoctal } {
|
40 |
|
|
# set input-radix = $iradix, output-radix = ten
|
41 |
|
|
gdb_test "set radix" \
|
42 |
|
|
"Input and output radices now set to decimal 10, hex a, octal 12." \
|
43 |
|
|
"initialize radix, input radix $iradix"
|
44 |
|
|
gdb_test "set input-radix $iradix" \
|
45 |
|
|
"Input radix now set to decimal $iradix, hex $iradixhex, octal $iradixoctal."
|
46 |
|
|
if { $iradix == 10 } then {
|
47 |
|
|
gdb_test "show radix" \
|
48 |
|
|
"Input and output radices set to decimal 10, hex a, octal 12." \
|
49 |
|
|
"show radix, input radix $iradix"
|
50 |
|
|
} else {
|
51 |
|
|
gdb_test "show radix" \
|
52 |
|
|
"Input radix set to decimal $iradix, hex $iradixhex, octal $iradixoctal.\r\nOutput radix set to decimal 10, hex a, octal 12." \
|
53 |
|
|
"show radix, input radix $iradix"
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
# test constants with specific bases that do not use $iradix
|
57 |
|
|
test_one_input $iradix "010" "8"
|
58 |
|
|
test_one_input $iradix "20." "20"
|
59 |
|
|
test_one_input $iradix "(int) 20." "20"
|
60 |
|
|
test_one_input $iradix "0xf" "15"
|
61 |
|
|
|
62 |
|
|
# test simple one-digit constants
|
63 |
|
|
test_one_input $iradix "0" "0"
|
64 |
|
|
test_one_input $iradix "1" "1"
|
65 |
|
|
test_one_input $iradix "-1" "-1"
|
66 |
|
|
|
67 |
|
|
# test simple two-digit constants
|
68 |
|
|
test_one_input $iradix "10" [expr $iradix]
|
69 |
|
|
test_one_input $iradix "11" [expr $iradix + 1]
|
70 |
|
|
test_one_input $iradix "-10" [expr 0 - $iradix]
|
71 |
|
|
test_one_input $iradix "-11" [expr 0 - $iradix - 1]
|
72 |
|
|
|
73 |
|
|
# test simple three-digit constants
|
74 |
|
|
test_one_input $iradix "100" [expr $iradix * $iradix]
|
75 |
|
|
test_one_input $iradix "101" [expr $iradix * $iradix + 1]
|
76 |
|
|
test_one_input $iradix "-100" [expr 0 - $iradix * $iradix]
|
77 |
|
|
test_one_input $iradix "-101" [expr 0 - $iradix * $iradix - 1]
|
78 |
|
|
|
79 |
|
|
# test a five-digit constant
|
80 |
|
|
test_one_input $iradix "10101" \
|
81 |
|
|
[expr $iradix * $iradix * $iradix * $iradix + $iradix * $iradix + 1]
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
test_input_radix 2 "2" "2"
|
85 |
|
|
test_one_input 2 "4" "Invalid number \"4\"\\."
|
86 |
|
|
test_one_input 2 "-2" "Invalid number \"2\"\\."
|
87 |
|
|
|
88 |
|
|
test_input_radix 3 "3" "3"
|
89 |
|
|
test_one_input 3 "2" "2"
|
90 |
|
|
test_one_input 3 "20" "6"
|
91 |
|
|
test_one_input 3 "3" "Invalid number \"3\"\\."
|
92 |
|
|
test_one_input 2 "30" "Invalid number \"30\"\\."
|
93 |
|
|
|
94 |
|
|
test_input_radix 8 "8" "10"
|
95 |
|
|
test_one_input 8 "20" "16"
|
96 |
|
|
test_one_input 8 "-20" "-16"
|
97 |
|
|
test_one_input 8 "8" "Invalid number \"8\"."
|
98 |
|
|
test_one_input 8 "-9" "Invalid number \"9\"."
|
99 |
|
|
|
100 |
|
|
test_input_radix 10 "a" "12"
|
101 |
|
|
test_one_input 10 "-12" "-12"
|
102 |
|
|
|
103 |
|
|
test_input_radix 16 "10" "20"
|
104 |
|
|
|
105 |
|
|
# Test output radices.
|
106 |
|
|
|
107 |
|
|
proc test_one_output { oradix input output } {
|
108 |
|
|
gdb_test "print $input" "$output" \
|
109 |
|
|
"print $input; expect $output; output radix $oradix"
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
proc test_output_radix { oradix oradixhex oradixoctal } {
|
113 |
|
|
# set input-radix = ten, output-radix = $oradix
|
114 |
|
|
gdb_test "set radix" \
|
115 |
|
|
"Input and output radices now set to decimal 10, hex a, octal 12." \
|
116 |
|
|
"initialize radix, output radix $oradix"
|
117 |
|
|
gdb_test "set output-radix $oradix" \
|
118 |
|
|
"Output radix now set to decimal $oradix, hex $oradixhex, octal $oradixoctal."
|
119 |
|
|
if { $oradix == 10 } then {
|
120 |
|
|
gdb_test "show radix" \
|
121 |
|
|
"Input and output radices set to decimal 10, hex a, octal 12." \
|
122 |
|
|
"show radix, output radix $oradix"
|
123 |
|
|
} else {
|
124 |
|
|
gdb_test "show radix" \
|
125 |
|
|
"Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal $oradix, hex $oradixhex, octal $oradixoctal." \
|
126 |
|
|
"show radix, output radix $oradix"
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
# no standard tests for output radix
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
test_output_radix 8 "8" "10"
|
133 |
|
|
test_one_output 8 "010" "010"
|
134 |
|
|
test_one_output 8 "0xf" "17"
|
135 |
|
|
test_one_output 8 "10" "12"
|
136 |
|
|
test_one_output 8 "100" "144"
|
137 |
|
|
setup_kfail *-*-* "gdb/1715"
|
138 |
|
|
test_one_output 8 "20." "24"
|
139 |
|
|
test_one_output 8 "(int) 20." "24"
|
140 |
|
|
|
141 |
|
|
test_output_radix 10 "a" "12"
|
142 |
|
|
test_one_output 10 "010" "8"
|
143 |
|
|
test_one_output 10 "0xf" "15"
|
144 |
|
|
test_one_output 10 "10" "10"
|
145 |
|
|
test_one_output 10 "100" "100"
|
146 |
|
|
test_one_output 10 "20." "20"
|
147 |
|
|
test_one_output 10 "(int) 20." "20"
|
148 |
|
|
|
149 |
|
|
test_output_radix 16 "10" "20"
|
150 |
|
|
test_one_output 16 "010" "8"
|
151 |
|
|
test_one_output 16 "0xf" "f"
|
152 |
|
|
test_one_output 16 "10" "a"
|
153 |
|
|
test_one_output 16 "100" "64"
|
154 |
|
|
setup_kfail *-*-* "gdb/1715"
|
155 |
|
|
test_one_output 16 "20." "14"
|
156 |
|
|
test_one_output 16 "(int) 20." "14"
|