1 # Copyright
(C
) 1994, 1997, 2005 Free Software Foundation
, Inc.
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.
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.
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.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-gdb@prep.ai.mit.edu
20 # This file was adapted from old Chill tests by Stan Shebs
30 #
Set the current language to fortran. This counts as a test.
If it
31 # fails
, then we skip the other tests.
33 proc set_lang_fortran
{} {
36 if [gdb_test
"set language fortran" ""] {
40 if ![gdb_test
"show language" ".* source language is \"fortran\".*"] {
47 proc test_integer_literals_accepted
{} {
50 # Test various decimal
values.
52 gdb_test
"p 123" " = 123"
53 gdb_test
"p -123" " = -123"
56 proc test_character_literals_accepted
{} {
59 # Test various character
values.
61 gdb_test
"p 'a'" " = 'a'"
63 # Test various substring expression.
64 gdb_test
"p 'abcdefg'(2:4)" " = 'bcd'"
65 gdb_test
"p 'abcdefg'(:3)" " = 'abc'"
66 gdb_test
"p 'abcdefg'(5:)" " = 'efg'"
67 gdb_test
"p 'abcdefg'(:)" " = 'abcdefg'"
71 proc test_integer_literals_rejected
{} {
74 test_print_reject
"p _"
77 proc test_logical_literals_accepted
{} {
80 # Test the only possible
values for a logical
, TRUE and FALSE.
82 gdb_test
"p .TRUE." " = .TRUE."
83 gdb_test
"p .FALSE." " = .FALSE."
86 proc test_float_literals_accepted
{} {
89 # Test various floating point formats
91 gdb_test
"p .44 .LT. .45" " = .TRUE."
92 gdb_test
"p .44 .GT. .45" " = .FALSE."
93 gdb_test
"p 0.44 .LT. 0.45" " = .TRUE."
94 gdb_test
"p 0.44 .GT. 0.45" " = .FALSE."
95 gdb_test
"p 44. .LT. 45." " = .TRUE."
96 gdb_test
"p 44. .GT. 45." " = .FALSE."
97 gdb_test
"p 44.0 .LT. 45.0" " = .TRUE."
98 gdb_test
"p 44.0 .GT. 45.0" " = .FALSE."
99 gdb_test
"p 10D20 .LT. 10D21" " = .TRUE."
100 gdb_test
"p 10D20 .GT. 10D21" " = .FALSE."
101 gdb_test
"p 10d20 .LT. 10d21" " = .TRUE."
102 gdb_test
"p 10d20 .GT. 10d21" " = .FALSE."
103 gdb_test
"p 10E20 .LT. 10E21" " = .TRUE."
104 gdb_test
"p 10E20 .GT. 10E21" " = .FALSE."
105 gdb_test
"p 10e20 .LT. 10e21" " = .TRUE."
106 gdb_test
"p 10e20 .GT. 10e21" " = .FALSE."
107 gdb_test
"p 10.D20 .LT. 10.D21" " = .TRUE."
108 gdb_test
"p 10.D20 .GT. 10.D21" " = .FALSE."
109 gdb_test
"p 10.d20 .LT. 10.d21" " = .TRUE."
110 gdb_test
"p 10.d20 .GT. 10.d21" " = .FALSE."
111 gdb_test
"p 10.E20 .LT. 10.E21" " = .TRUE."
112 gdb_test
"p 10.E20 .GT. 10.E21" " = .FALSE."
113 gdb_test
"p 10.e20 .LT. 10.e21" " = .TRUE."
114 gdb_test
"p 10.e20 .GT. 10.e21" " = .FALSE."
115 gdb_test
"p 10.0D20 .LT. 10.0D21" " = .TRUE."
116 gdb_test
"p 10.0D20 .GT. 10.0D21" " = .FALSE."
117 gdb_test
"p 10.0d20 .LT. 10.0d21" " = .TRUE."
118 gdb_test
"p 10.0d20 .GT. 10.0d21" " = .FALSE."
119 gdb_test
"p 10.0E20 .LT. 10.0E21" " = .TRUE."
120 gdb_test
"p 10.0E20 .GT. 10.0E21" " = .FALSE."
121 gdb_test
"p 10.0e20 .LT. 10.0e21" " = .TRUE."
122 gdb_test
"p 10.0e20 .GT. 10.0e21" " = .FALSE."
123 gdb_test
"p 10.0D+20 .LT. 10.0D+21" " = .TRUE."
124 gdb_test
"p 10.0D+20 .GT. 10.0D+21" " = .FALSE."
125 gdb_test
"p 10.0d+20 .LT. 10.0d+21" " = .TRUE."
126 gdb_test
"p 10.0d+20 .GT. 10.0d+21" " = .FALSE."
127 gdb_test
"p 10.0E+20 .LT. 10.0E+21" " = .TRUE."
128 gdb_test
"p 10.0E+20 .GT. 10.0E+21" " = .FALSE."
129 gdb_test
"p 10.0e+20 .LT. 10.0e+21" " = .TRUE."
130 gdb_test
"p 10.0e+20 .GT. 10.0e+21" " = .FALSE."
131 gdb_test
"p 10.0D-11 .LT. 10.0D-10" " = .TRUE."
132 gdb_test
"p 10.0D-11 .GT. 10.0D-10" " = .FALSE."
133 gdb_test
"p 10.0d-11 .LT. 10.0d-10" " = .TRUE."
134 gdb_test
"p 10.0d-11 .GT. 10.0d-10" " = .FALSE."
135 gdb_test
"p 10.0E-11 .LT. 10.0E-10" " = .TRUE."
136 gdb_test
"p 10.0E-11 .GT. 10.0E-10" " = .FALSE."
137 gdb_test
"p 10.0e-11 .LT. 10.0e-10" " = .TRUE."
138 gdb_test
"p 10.0e-11 .GT. 10.0e-10" " = .FALSE."
141 proc test_convenience_variables
{} {
144 gdb_test
"set \$foo = 101" " = 101\[\r\n\]*" \
145 "Set a new convenience variable"
147 gdb_test
"print \$foo" " = 101" \
148 "Print contents of new convenience variable"
150 gdb_test
"set \$foo = 301" " = 301\[\r\n\]*" \
151 "Set convenience variable to a new value"
153 gdb_test
"print \$foo" " = 301" \
154 "Print new contents of convenience variable"
156 gdb_test
"set \$_ = 11" " = 11\[\r\n\]*" \
157 "Set convenience variable \$_"
159 gdb_test
"print \$_" " = 11" \
160 "Print contents of convenience variable \$_"
162 gdb_test
"print \$foo + 10" " = 311" \
163 "Use convenience variable in arithmetic expression"
165 gdb_test
"print (\$foo = 32) + 4" " = 36" \
166 "Use convenience variable assignment in arithmetic expression"
168 gdb_test
"print \$bar" " = VOID" \
169 "Print contents of uninitialized convenience variable"
172 proc test_value_history
{} {
175 gdb_test
"print 101" "\\\$1 = 101" \
176 "Set value-history\[1\] using \$1"
178 gdb_test
"print 102" "\\\$2 = 102" \
179 "Set value-history\[2\] using \$2"
181 gdb_test
"print 103" "\\\$3 = 103" \
182 "Set value-history\[3\] using \$3"
184 gdb_test
"print \$\$" "\\\$4 = 102" \
185 "Print value-history\[MAX-1\] using inplicit index \$\$"
187 gdb_test
"print \$\$" "\\\$5 = 103" \
188 "Print value-history\[MAX-1\] again using implicit index \$\$"
190 gdb_test
"print \$" "\\\$6 = 103" \
191 "Print value-history\[MAX\] using implicit index \$"
193 gdb_test
"print \$\$2" "\\\$7 = 102" \
194 "Print value-history\[MAX-2\] using explicit index \$\$2"
196 gdb_test
"print \$0" "\\\$8 = 102" \
197 "Print value-history\[MAX\] using explicit index \$0"
199 gdb_test
"print 108" "\\\$9 = 108" ""
201 gdb_test
"print \$\$0" "\\\$10 = 108" \
202 "Print value-history\[MAX\] using explicit index \$\$0"
204 gdb_test
"print \$1" "\\\$11 = 101" \
205 "Print value-history\[1\] using explicit index \$1"
207 gdb_test
"print \$2" "\\\$12 = 102" \
208 "Print value-history\[2\] using explicit index \$2"
210 gdb_test
"print \$3" "\\\$13 = 103" \
211 "Print value-history\[3\] using explicit index \$3"
213 gdb_test
"print \$-3" "\\\$14 = 100" \
214 "Print (value-history\[MAX\] - 3) using implicit index \$"
216 gdb_test
"print \$1 + 3" "\\\$15 = 104" \
217 "Use value-history element in arithmetic expression"
220 proc test_arithmetic_expressions
{} {
223 # Test unary minus with various operands
225 # gdb_test
"p -(TRUE)" " = -1" "unary minus applied to bool"
226 # gdb_test
"p -('a')" " = xxx" "unary minus applied to char"
227 gdb_test
"p -(1)" " = -1" "unary minus applied to int"
228 gdb_test
"p -(1.0)" " = -1" "unary minus applied to real"
230 # Test addition with various operands
232 gdb_test
"p .TRUE. + 1" " = 2" "bool plus int"
233 gdb_test
"p 1 + 1" " = 2" "int plus int"
234 gdb_test
"p 1.0 + 1" " = 2" "real plus int"
235 gdb_test
"p 1.0 + 2.0" " = 3" "real plus real"
237 # Test subtraction with various operands
239 gdb_test
"p .TRUE. - 1" " = 0" "bool minus int"
240 gdb_test
"p 3 - 1" " = 2" "int minus int"
241 gdb_test
"p 3.0 - 1" " = 2" "real minus int"
242 gdb_test
"p 5.0 - 2.0" " = 3" "real minus real"
244 # Test multiplication with various operands
246 gdb_test
"p .TRUE. * 1" " = 1" "bool times int"
247 gdb_test
"p 2 * 3" " = 6" "int times int"
248 gdb_test
"p 2.0 * 3" " = 6" "real times int"
249 gdb_test
"p 2.0 * 3.0" " = 6" "real times real"
251 # Test division with various operands
253 gdb_test
"p .TRUE. / 1" " = 1" "bool divided by int"
254 gdb_test
"p 6 / 3" " = 2" "int divided by int"
255 gdb_test
"p 6.0 / 3" " = 2" "real divided by int"
256 gdb_test
"p 6.0 / 3.0" " = 2" "real divided by real"
258 # Test exponentiation with various operands
260 gdb_test
"p 2 ** 3" " = 8" "int powered by int"
261 gdb_test
"p 2 ** 2 ** 3" " = 256" "combined exponentiation expression"
262 gdb_test
"p (2 ** 2) ** 3" " = 64" "combined exponentiation expression in specified order"
263 gdb_test
"p 4 ** 0.5" " = 2" "int powered by real"
264 gdb_test
"p 4.0 ** 0.5" " = 2" "real powered by real"
268 # Start with a fresh gdb.
272 gdb_reinitialize_dir $srcdir
/$subdir
274 gdb_test
"set print sevenbit-strings" ""
276 if [set_lang_fortran
] then {
278 test_convenience_variables
279 test_integer_literals_accepted
280 test_integer_literals_rejected
281 test_logical_literals_accepted
282 test_character_literals_accepted
283 test_float_literals_accepted
284 test_arithmetic_expressions
286 warning
"$test_name tests suppressed." 0