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