1 # Copyright 1998, 1999, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
19 # This file is part of the gdb testsuite
21 # tests for arithmetic, logical and relational operators
32 # test running programs
35 set testfile "all-types"
36 set srcfile ${testfile}.c
37 set binfile ${objdir}/${subdir}/${testfile}
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
44 if [get_compiler_info ${binfile}] {
50 gdb_reinitialize_dir $srcdir/$subdir
55 # set it up at a breakpoint so we can play with the variable values
58 if ![runto_main] then {
59 perror "couldn't run to breakpoint"
63 gdb_test "next" "return 0;" "continuing after dummy()"
65 gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char"
67 gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short"
69 gdb_test "print v_int+v_signed_char" " = 72" \
70 "print value of v_int+v_signed_char"
72 gdb_test "print v_int+v_unsigned_char" " = 73" \
73 "print value of v_int+v_unsigned_char"
75 gdb_test "print v_int+v_signed_short" " = 10" \
76 "print value of v_int+v_signed_short"
78 gdb_test "print v_int+v_unsigned_short" " = 11" \
79 "print value of v_int+v_unsigned_short"
81 gdb_test "print v_int+v_signed_int" " = 13" \
82 "print value of v_int+v_signed_int"
84 gdb_test "print v_int+v_unsigned_int" " = 14" \
85 "print value of v_int+v_unsigned_int"
87 gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long"
89 gdb_test "print v_int+v_signed_long" " = 16" \
90 "print value of v_int+v_signed_long"
92 gdb_test "print v_int+v_unsigned_long" " = 17" \
93 "print value of v_int+v_unsigned_long"
95 gdb_test "print v_int+v_float" " = 106.34343.*" \
96 "print value of v_int+v_float"
98 gdb_test "print v_int+v_double" " = 206.565.*" \
99 "print value of v_int+v_double"
103 # test the relational operators with mixed types
106 gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char"
108 gdb_test "print v_int <= v_short" " = $false" \
109 "print value of v_int<=v_short"
111 gdb_test "print v_int <= v_signed_char" " = 1" \
112 "print value of v_int<=v_signed_char"
114 gdb_test "print v_int <= v_unsigned_char" " = 1" \
115 "print value of v_int<=v_unsigned_char"
117 gdb_test "print v_int <= v_signed_short" " = $false" \
118 "print value of v_int<=v_signed_short"
120 gdb_test "print v_int <= v_unsigned_short" " = $false" \
121 "print value of v_int<=v_unsigned_short"
123 gdb_test "print v_int <= v_signed_int" " = $true" \
124 "print value of v_int<=v_signed_int"
126 gdb_test "print v_int <= v_unsigned_int" " = $true" \
127 "print value of v_int<=v_unsigned_int"
129 gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long"
131 gdb_test "print v_int <= v_signed_long" " = $true" \
132 "print value of v_int<=v_signed_long"
134 gdb_test "print v_int <= v_unsigned_long" " = $true" \
135 "print value of v_int<=v_unsigned_long"
137 gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float"
139 gdb_test "print v_int <= v_double" " = $true" \
140 "print value of v_int<=v_double"
143 # test the logical operators with mixed types
146 gdb_test_no_output "set variable v_char=0" "set v_char=0"
147 gdb_test_no_output "set variable v_double=0.0" "set v_double=0"
148 gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0"
150 gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char"
152 gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short"
154 gdb_test "print v_int && v_signed_char" " = $true" \
155 "print value of v_int&&v_signed_char"
157 gdb_test "print v_int && v_unsigned_char" " = $true" \
158 "print value of v_int&&v_unsigned_char"
160 gdb_test "print v_int && v_signed_short" " = $true" \
161 "print value of v_int&&v_signed_short"
163 gdb_test "print v_int && v_unsigned_short" " = $true" \
164 "print value of v_int&&v_unsigned_short"
166 gdb_test "print v_int && v_signed_int" " = $true" \
167 "print value of v_int&&v_signed_int"
169 gdb_test "print v_int && v_unsigned_int" " = $true" \
170 "print value of v_int&&v_unsigned_int"
172 gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long"
174 gdb_test "print v_int && v_signed_long" " = $true" \
175 "print value of v_int&&v_signed_long"
177 gdb_test "print v_int && v_unsigned_long" " = $false" \
178 "print value of v_int&&v_unsigned_long"
180 gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float"
182 gdb_test "print v_int && v_double" " = $false" \
183 "print value of v_int&&v_double"