Commit | Line | Data |
---|---|---|
7b6bb8da JB |
1 | # Copyright 1998, 1999, 2007, 2008, 2009, 2010, 2011 |
2 | # Free Software Foundation, Inc. | |
c906108c SS |
3 | |
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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
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. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) |
18 | ||
19 | # This file is part of the gdb testsuite | |
20 | # | |
21 | # tests for arithmetic, logical and relational operators | |
22 | # with mixed types | |
23 | # | |
24 | ||
25 | ||
26 | ||
27 | if $tracelevel then { | |
28 | strace $tracelevel | |
29 | } | |
30 | ||
31 | # | |
32 | # test running programs | |
33 | # | |
c906108c SS |
34 | |
35 | set testfile "all-types" | |
36 | set srcfile ${testfile}.c | |
37 | set binfile ${objdir}/${subdir}/${testfile} | |
38 | ||
fc91c6c2 | 39 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { |
b60f0898 JB |
40 | untested all-bin.exp |
41 | return -1 | |
c906108c SS |
42 | } |
43 | ||
085dd6e6 JM |
44 | if [get_compiler_info ${binfile}] { |
45 | return -1 | |
46 | } | |
47 | ||
c906108c SS |
48 | gdb_exit |
49 | gdb_start | |
50 | gdb_reinitialize_dir $srcdir/$subdir | |
51 | gdb_load ${binfile} | |
52 | ||
53 | ||
54 | # | |
55 | # set it up at a breakpoint so we can play with the variable values | |
56 | # | |
57 | ||
58 | if ![runto_main] then { | |
59 | perror "couldn't run to breakpoint" | |
60 | continue | |
61 | } | |
62 | ||
63 | gdb_test "next" "return 0;" "continuing after dummy()" | |
64 | ||
6acb16a2 MS |
65 | gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char" |
66 | ||
67 | gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short" | |
68 | ||
69 | gdb_test "print v_int+v_signed_char" " = 72" \ | |
70 | "print value of v_int+v_signed_char" | |
71 | ||
72 | gdb_test "print v_int+v_unsigned_char" " = 73" \ | |
73 | "print value of v_int+v_unsigned_char" | |
74 | ||
75 | gdb_test "print v_int+v_signed_short" " = 10" \ | |
76 | "print value of v_int+v_signed_short" | |
77 | ||
78 | gdb_test "print v_int+v_unsigned_short" " = 11" \ | |
79 | "print value of v_int+v_unsigned_short" | |
80 | ||
81 | gdb_test "print v_int+v_signed_int" " = 13" \ | |
82 | "print value of v_int+v_signed_int" | |
83 | ||
84 | gdb_test "print v_int+v_unsigned_int" " = 14" \ | |
85 | "print value of v_int+v_unsigned_int" | |
86 | ||
87 | gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long" | |
88 | ||
89 | gdb_test "print v_int+v_signed_long" " = 16" \ | |
90 | "print value of v_int+v_signed_long" | |
91 | ||
92 | gdb_test "print v_int+v_unsigned_long" " = 17" \ | |
93 | "print value of v_int+v_unsigned_long" | |
94 | ||
95 | gdb_test "print v_int+v_float" " = 106.34343.*" \ | |
96 | "print value of v_int+v_float" | |
97 | ||
98 | gdb_test "print v_int+v_double" " = 206.565.*" \ | |
99 | "print value of v_int+v_double" | |
c906108c SS |
100 | |
101 | ||
102 | # | |
103 | # test the relational operators with mixed types | |
104 | # | |
105 | ||
6acb16a2 MS |
106 | gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char" |
107 | ||
108 | gdb_test "print v_int <= v_short" " = $false" \ | |
109 | "print value of v_int<=v_short" | |
110 | ||
111 | gdb_test "print v_int <= v_signed_char" " = 1" \ | |
112 | "print value of v_int<=v_signed_char" | |
113 | ||
114 | gdb_test "print v_int <= v_unsigned_char" " = 1" \ | |
115 | "print value of v_int<=v_unsigned_char" | |
116 | ||
117 | gdb_test "print v_int <= v_signed_short" " = $false" \ | |
118 | "print value of v_int<=v_signed_short" | |
119 | ||
120 | gdb_test "print v_int <= v_unsigned_short" " = $false" \ | |
121 | "print value of v_int<=v_unsigned_short" | |
c906108c | 122 | |
6acb16a2 MS |
123 | gdb_test "print v_int <= v_signed_int" " = $true" \ |
124 | "print value of v_int<=v_signed_int" | |
c906108c | 125 | |
6acb16a2 MS |
126 | gdb_test "print v_int <= v_unsigned_int" " = $true" \ |
127 | "print value of v_int<=v_unsigned_int" | |
128 | ||
129 | gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long" | |
130 | ||
131 | gdb_test "print v_int <= v_signed_long" " = $true" \ | |
132 | "print value of v_int<=v_signed_long" | |
133 | ||
134 | gdb_test "print v_int <= v_unsigned_long" " = $true" \ | |
135 | "print value of v_int<=v_unsigned_long" | |
136 | ||
137 | gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float" | |
138 | ||
139 | gdb_test "print v_int <= v_double" " = $true" \ | |
140 | "print value of v_int<=v_double" | |
c906108c SS |
141 | |
142 | # | |
143 | # test the logical operators with mixed types | |
144 | # | |
145 | ||
6acb16a2 MS |
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" | |
149 | ||
150 | gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char" | |
151 | ||
152 | gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short" | |
153 | ||
154 | gdb_test "print v_int && v_signed_char" " = $true" \ | |
155 | "print value of v_int&&v_signed_char" | |
156 | ||
157 | gdb_test "print v_int && v_unsigned_char" " = $true" \ | |
158 | "print value of v_int&&v_unsigned_char" | |
159 | ||
160 | gdb_test "print v_int && v_signed_short" " = $true" \ | |
161 | "print value of v_int&&v_signed_short" | |
162 | ||
163 | gdb_test "print v_int && v_unsigned_short" " = $true" \ | |
164 | "print value of v_int&&v_unsigned_short" | |
165 | ||
166 | gdb_test "print v_int && v_signed_int" " = $true" \ | |
167 | "print value of v_int&&v_signed_int" | |
168 | ||
169 | gdb_test "print v_int && v_unsigned_int" " = $true" \ | |
170 | "print value of v_int&&v_unsigned_int" | |
171 | ||
172 | gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long" | |
173 | ||
174 | gdb_test "print v_int && v_signed_long" " = $true" \ | |
175 | "print value of v_int&&v_signed_long" | |
176 | ||
177 | gdb_test "print v_int && v_unsigned_long" " = $false" \ | |
178 | "print value of v_int&&v_unsigned_long" | |
179 | ||
180 | gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float" | |
181 | ||
182 | gdb_test "print v_int && v_double" " = $false" \ | |
183 | "print value of v_int&&v_double" | |
c906108c SS |
184 | |
185 | ||
186 | ||
187 | ||
188 |