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
27 # test running programs
30 set testfile "all-types"
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
39 if [get_compiler_info] {
45 gdb_reinitialize_dir $srcdir/$subdir
50 # set it up at a breakpoint so we can play with the variable values
53 if ![runto_main] then {
54 perror "couldn't run to breakpoint"
58 gdb_test "next" "return 0;" "continuing after dummy()"
60 gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char"
62 gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short"
64 gdb_test "print v_int+v_signed_char" " = 72" \
65 "print value of v_int+v_signed_char"
67 gdb_test "print v_int+v_unsigned_char" " = 73" \
68 "print value of v_int+v_unsigned_char"
70 gdb_test "print v_int+v_signed_short" " = 10" \
71 "print value of v_int+v_signed_short"
73 gdb_test "print v_int+v_unsigned_short" " = 11" \
74 "print value of v_int+v_unsigned_short"
76 gdb_test "print v_int+v_signed_int" " = 13" \
77 "print value of v_int+v_signed_int"
79 gdb_test "print v_int+v_unsigned_int" " = 14" \
80 "print value of v_int+v_unsigned_int"
82 gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long"
84 gdb_test "print v_int+v_signed_long" " = 16" \
85 "print value of v_int+v_signed_long"
87 gdb_test "print v_int+v_unsigned_long" " = 17" \
88 "print value of v_int+v_unsigned_long"
90 gdb_test "print v_int+v_float" " = 106.34343.*" \
91 "print value of v_int+v_float"
93 gdb_test "print v_int+v_double" " = 206.565.*" \
94 "print value of v_int+v_double"
98 # test the relational operators with mixed types
101 gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char"
103 gdb_test "print v_int <= v_short" " = $false" \
104 "print value of v_int<=v_short"
106 gdb_test "print v_int <= v_signed_char" " = 1" \
107 "print value of v_int<=v_signed_char"
109 gdb_test "print v_int <= v_unsigned_char" " = 1" \
110 "print value of v_int<=v_unsigned_char"
112 gdb_test "print v_int <= v_signed_short" " = $false" \
113 "print value of v_int<=v_signed_short"
115 gdb_test "print v_int <= v_unsigned_short" " = $false" \
116 "print value of v_int<=v_unsigned_short"
118 gdb_test "print v_int <= v_signed_int" " = $true" \
119 "print value of v_int<=v_signed_int"
121 gdb_test "print v_int <= v_unsigned_int" " = $true" \
122 "print value of v_int<=v_unsigned_int"
124 gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long"
126 gdb_test "print v_int <= v_signed_long" " = $true" \
127 "print value of v_int<=v_signed_long"
129 gdb_test "print v_int <= v_unsigned_long" " = $true" \
130 "print value of v_int<=v_unsigned_long"
132 gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float"
134 gdb_test "print v_int <= v_double" " = $true" \
135 "print value of v_int<=v_double"
138 # test the logical operators with mixed types
141 gdb_test_no_output "set variable v_char=0" "set v_char=0"
142 gdb_test_no_output "set variable v_double=0.0" "set v_double=0"
143 gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0"
145 gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char"
147 gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short"
149 gdb_test "print v_int && v_signed_char" " = $true" \
150 "print value of v_int&&v_signed_char"
152 gdb_test "print v_int && v_unsigned_char" " = $true" \
153 "print value of v_int&&v_unsigned_char"
155 gdb_test "print v_int && v_signed_short" " = $true" \
156 "print value of v_int&&v_signed_short"
158 gdb_test "print v_int && v_unsigned_short" " = $true" \
159 "print value of v_int&&v_unsigned_short"
161 gdb_test "print v_int && v_signed_int" " = $true" \
162 "print value of v_int&&v_signed_int"
164 gdb_test "print v_int && v_unsigned_int" " = $true" \
165 "print value of v_int&&v_unsigned_int"
167 gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long"
169 gdb_test "print v_int && v_signed_long" " = $true" \
170 "print value of v_int&&v_signed_long"
172 gdb_test "print v_int && v_unsigned_long" " = $false" \
173 "print value of v_int&&v_unsigned_long"
175 gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float"
177 gdb_test "print v_int && v_double" " = $false" \
178 "print value of v_int&&v_double"