1 # Copyright
1998-2019 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
3 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
, see
<http
://www.gnu.org
/licenses
/>.
16 # This file was written by Elena Zannoni
(ezannoni@cygnus.com
)
18 # This file is part of the gdb testsuite
20 # tests
for arithmetic
, logical and relational operators
27 # test running programs
30 standard_testfile all
-types.c
32 if [get_compiler_info
] {
36 if {[prepare_for_testing
"failed to prepare" $testfile $srcfile debug]} {
41 #
set it up at a breakpoint so we can play with the
variable values
44 if ![runto_main
] then {
45 perror
"couldn't run to breakpoint"
49 gdb_test
"next" "return 0;" "continuing after dummy()"
51 gdb_test
"print v_int+v_char" " = 71" "print value of v_int+v_char"
53 gdb_test
"print v_int+v_short" " = 9" "print value of v_int+v_short"
55 gdb_test
"print v_int+v_signed_char" " = 72" \
56 "print value of v_int+v_signed_char"
58 gdb_test
"print v_int+v_unsigned_char" " = 73" \
59 "print value of v_int+v_unsigned_char"
61 gdb_test
"print v_int+v_signed_short" " = 10" \
62 "print value of v_int+v_signed_short"
64 gdb_test
"print v_int+v_unsigned_short" " = 11" \
65 "print value of v_int+v_unsigned_short"
67 gdb_test
"print v_int+v_signed_int" " = 13" \
68 "print value of v_int+v_signed_int"
70 gdb_test
"print v_int+v_unsigned_int" " = 14" \
71 "print value of v_int+v_unsigned_int"
73 gdb_test
"print v_int+v_long" " = 15" "print value of v_int+v_long"
75 gdb_test
"print v_int+v_signed_long" " = 16" \
76 "print value of v_int+v_signed_long"
78 gdb_test
"print v_int+v_unsigned_long" " = 17" \
79 "print value of v_int+v_unsigned_long"
81 gdb_test
"print v_int+v_float" " = 106.34343.*" \
82 "print value of v_int+v_float"
84 gdb_test
"print v_int+v_double" " = 206.565.*" \
85 "print value of v_int+v_double"
89 # test the relational operators with mixed types
92 gdb_test
"print v_int <= v_char" " = 1" "print value of v_int<=v_char"
94 gdb_test
"print v_int <= v_short" " = $false" \
95 "print value of v_int<=v_short"
97 gdb_test
"print v_int <= v_signed_char" " = 1" \
98 "print value of v_int<=v_signed_char"
100 gdb_test
"print v_int <= v_unsigned_char" " = 1" \
101 "print value of v_int<=v_unsigned_char"
103 gdb_test
"print v_int <= v_signed_short" " = $false" \
104 "print value of v_int<=v_signed_short"
106 gdb_test
"print v_int <= v_unsigned_short" " = $false" \
107 "print value of v_int<=v_unsigned_short"
109 gdb_test
"print v_int <= v_signed_int" " = $true" \
110 "print value of v_int<=v_signed_int"
112 gdb_test
"print v_int <= v_unsigned_int" " = $true" \
113 "print value of v_int<=v_unsigned_int"
115 gdb_test
"print v_int <= v_long" " = $true" "print value of v_int<=v_long"
117 gdb_test
"print v_int <= v_signed_long" " = $true" \
118 "print value of v_int<=v_signed_long"
120 gdb_test
"print v_int <= v_unsigned_long" " = $true" \
121 "print value of v_int<=v_unsigned_long"
123 gdb_test
"print v_int <= v_float" " = $true" "print value of v_int<=v_float"
125 gdb_test
"print v_int <= v_double" " = $true" \
126 "print value of v_int<=v_double"
129 # test the logical operators with mixed types
132 gdb_test_no_output
"set variable v_char=0" "set v_char=0"
133 gdb_test_no_output
"set variable v_double=0.0" "set v_double=0"
134 gdb_test_no_output
"set variable v_unsigned_long=0" "set v_unsigned_long=0"
136 gdb_test
"print v_int && v_char" " = $false" "print value of v_int&&v_char"
138 gdb_test
"print v_int && v_short" " = $true" "print value of v_int&&v_short"
140 gdb_test
"print v_int && v_signed_char" " = $true" \
141 "print value of v_int&&v_signed_char"
143 gdb_test
"print v_int && v_unsigned_char" " = $true" \
144 "print value of v_int&&v_unsigned_char"
146 gdb_test
"print v_int && v_signed_short" " = $true" \
147 "print value of v_int&&v_signed_short"
149 gdb_test
"print v_int && v_unsigned_short" " = $true" \
150 "print value of v_int&&v_unsigned_short"
152 gdb_test
"print v_int && v_signed_int" " = $true" \
153 "print value of v_int&&v_signed_int"
155 gdb_test
"print v_int && v_unsigned_int" " = $true" \
156 "print value of v_int&&v_unsigned_int"
158 gdb_test
"print v_int && v_long" " = $true" "print value of v_int&&v_long"
160 gdb_test
"print v_int && v_signed_long" " = $true" \
161 "print value of v_int&&v_signed_long"
163 gdb_test
"print v_int && v_unsigned_long" " = $false" \
164 "print value of v_int&&v_unsigned_long"
166 gdb_test
"print v_int && v_float" " = $true" "print value of v_int&&v_float"
168 gdb_test
"print v_int && v_double" " = $false" \
169 "print value of v_int&&v_double"