1 # Copyright 1998-1999, 2007-2012 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
31 # test running programs
34 set testfile "all-types"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
43 if [get_compiler_info ${binfile}] {
49 gdb_reinitialize_dir $srcdir/$subdir
54 # set it up at a breakpoint so we can play with the variable values
57 if ![runto_main] then {
58 perror "couldn't run to breakpoint"
62 gdb_test "next" "return 0;" "continuing after dummy()"
64 gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char"
66 gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short"
68 gdb_test "print v_int+v_signed_char" " = 72" \
69 "print value of v_int+v_signed_char"
71 gdb_test "print v_int+v_unsigned_char" " = 73" \
72 "print value of v_int+v_unsigned_char"
74 gdb_test "print v_int+v_signed_short" " = 10" \
75 "print value of v_int+v_signed_short"
77 gdb_test "print v_int+v_unsigned_short" " = 11" \
78 "print value of v_int+v_unsigned_short"
80 gdb_test "print v_int+v_signed_int" " = 13" \
81 "print value of v_int+v_signed_int"
83 gdb_test "print v_int+v_unsigned_int" " = 14" \
84 "print value of v_int+v_unsigned_int"
86 gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long"
88 gdb_test "print v_int+v_signed_long" " = 16" \
89 "print value of v_int+v_signed_long"
91 gdb_test "print v_int+v_unsigned_long" " = 17" \
92 "print value of v_int+v_unsigned_long"
94 gdb_test "print v_int+v_float" " = 106.34343.*" \
95 "print value of v_int+v_float"
97 gdb_test "print v_int+v_double" " = 206.565.*" \
98 "print value of v_int+v_double"
102 # test the relational operators with mixed types
105 gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char"
107 gdb_test "print v_int <= v_short" " = $false" \
108 "print value of v_int<=v_short"
110 gdb_test "print v_int <= v_signed_char" " = 1" \
111 "print value of v_int<=v_signed_char"
113 gdb_test "print v_int <= v_unsigned_char" " = 1" \
114 "print value of v_int<=v_unsigned_char"
116 gdb_test "print v_int <= v_signed_short" " = $false" \
117 "print value of v_int<=v_signed_short"
119 gdb_test "print v_int <= v_unsigned_short" " = $false" \
120 "print value of v_int<=v_unsigned_short"
122 gdb_test "print v_int <= v_signed_int" " = $true" \
123 "print value of v_int<=v_signed_int"
125 gdb_test "print v_int <= v_unsigned_int" " = $true" \
126 "print value of v_int<=v_unsigned_int"
128 gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long"
130 gdb_test "print v_int <= v_signed_long" " = $true" \
131 "print value of v_int<=v_signed_long"
133 gdb_test "print v_int <= v_unsigned_long" " = $true" \
134 "print value of v_int<=v_unsigned_long"
136 gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float"
138 gdb_test "print v_int <= v_double" " = $true" \
139 "print value of v_int<=v_double"
142 # test the logical operators with mixed types
145 gdb_test_no_output "set variable v_char=0" "set v_char=0"
146 gdb_test_no_output "set variable v_double=0.0" "set v_double=0"
147 gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0"
149 gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char"
151 gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short"
153 gdb_test "print v_int && v_signed_char" " = $true" \
154 "print value of v_int&&v_signed_char"
156 gdb_test "print v_int && v_unsigned_char" " = $true" \
157 "print value of v_int&&v_unsigned_char"
159 gdb_test "print v_int && v_signed_short" " = $true" \
160 "print value of v_int&&v_signed_short"
162 gdb_test "print v_int && v_unsigned_short" " = $true" \
163 "print value of v_int&&v_unsigned_short"
165 gdb_test "print v_int && v_signed_int" " = $true" \
166 "print value of v_int&&v_signed_int"
168 gdb_test "print v_int && v_unsigned_int" " = $true" \
169 "print value of v_int&&v_unsigned_int"
171 gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long"
173 gdb_test "print v_int && v_signed_long" " = $true" \
174 "print value of v_int&&v_signed_long"
176 gdb_test "print v_int && v_unsigned_long" " = $false" \
177 "print value of v_int&&v_unsigned_long"
179 gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float"
181 gdb_test "print v_int && v_double" " = $false" \
182 "print value of v_int&&v_double"