Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright 1998-2018 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 | 29 | |
a64d2530 | 30 | standard_testfile all-types.c |
c906108c | 31 | |
4c93b1db | 32 | if [get_compiler_info] { |
085dd6e6 JM |
33 | return -1 |
34 | } | |
35 | ||
5b362f04 | 36 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
a64d2530 TT |
37 | return -1 |
38 | } | |
c906108c SS |
39 | |
40 | # | |
41 | # set it up at a breakpoint so we can play with the variable values | |
42 | # | |
43 | ||
44 | if ![runto_main] then { | |
45 | perror "couldn't run to breakpoint" | |
46 | continue | |
47 | } | |
48 | ||
49 | gdb_test "next" "return 0;" "continuing after dummy()" | |
50 | ||
6acb16a2 MS |
51 | gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char" |
52 | ||
53 | gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short" | |
54 | ||
55 | gdb_test "print v_int+v_signed_char" " = 72" \ | |
56 | "print value of v_int+v_signed_char" | |
57 | ||
58 | gdb_test "print v_int+v_unsigned_char" " = 73" \ | |
59 | "print value of v_int+v_unsigned_char" | |
60 | ||
61 | gdb_test "print v_int+v_signed_short" " = 10" \ | |
62 | "print value of v_int+v_signed_short" | |
63 | ||
64 | gdb_test "print v_int+v_unsigned_short" " = 11" \ | |
65 | "print value of v_int+v_unsigned_short" | |
66 | ||
67 | gdb_test "print v_int+v_signed_int" " = 13" \ | |
68 | "print value of v_int+v_signed_int" | |
69 | ||
70 | gdb_test "print v_int+v_unsigned_int" " = 14" \ | |
71 | "print value of v_int+v_unsigned_int" | |
72 | ||
73 | gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long" | |
74 | ||
75 | gdb_test "print v_int+v_signed_long" " = 16" \ | |
76 | "print value of v_int+v_signed_long" | |
77 | ||
78 | gdb_test "print v_int+v_unsigned_long" " = 17" \ | |
79 | "print value of v_int+v_unsigned_long" | |
80 | ||
81 | gdb_test "print v_int+v_float" " = 106.34343.*" \ | |
82 | "print value of v_int+v_float" | |
83 | ||
84 | gdb_test "print v_int+v_double" " = 206.565.*" \ | |
85 | "print value of v_int+v_double" | |
c906108c SS |
86 | |
87 | ||
88 | # | |
89 | # test the relational operators with mixed types | |
90 | # | |
91 | ||
6acb16a2 MS |
92 | gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char" |
93 | ||
94 | gdb_test "print v_int <= v_short" " = $false" \ | |
95 | "print value of v_int<=v_short" | |
96 | ||
97 | gdb_test "print v_int <= v_signed_char" " = 1" \ | |
98 | "print value of v_int<=v_signed_char" | |
99 | ||
100 | gdb_test "print v_int <= v_unsigned_char" " = 1" \ | |
101 | "print value of v_int<=v_unsigned_char" | |
102 | ||
103 | gdb_test "print v_int <= v_signed_short" " = $false" \ | |
104 | "print value of v_int<=v_signed_short" | |
105 | ||
106 | gdb_test "print v_int <= v_unsigned_short" " = $false" \ | |
107 | "print value of v_int<=v_unsigned_short" | |
c906108c | 108 | |
6acb16a2 MS |
109 | gdb_test "print v_int <= v_signed_int" " = $true" \ |
110 | "print value of v_int<=v_signed_int" | |
c906108c | 111 | |
6acb16a2 MS |
112 | gdb_test "print v_int <= v_unsigned_int" " = $true" \ |
113 | "print value of v_int<=v_unsigned_int" | |
114 | ||
115 | gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long" | |
116 | ||
117 | gdb_test "print v_int <= v_signed_long" " = $true" \ | |
118 | "print value of v_int<=v_signed_long" | |
119 | ||
120 | gdb_test "print v_int <= v_unsigned_long" " = $true" \ | |
121 | "print value of v_int<=v_unsigned_long" | |
122 | ||
123 | gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float" | |
124 | ||
125 | gdb_test "print v_int <= v_double" " = $true" \ | |
126 | "print value of v_int<=v_double" | |
c906108c SS |
127 | |
128 | # | |
129 | # test the logical operators with mixed types | |
130 | # | |
131 | ||
6acb16a2 MS |
132 | gdb_test_no_output "set variable v_char=0" "set v_char=0" |
133 | gdb_test_no_output "set variable v_double=0.0" "set v_double=0" | |
134 | gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0" | |
135 | ||
136 | gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char" | |
137 | ||
138 | gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short" | |
139 | ||
140 | gdb_test "print v_int && v_signed_char" " = $true" \ | |
141 | "print value of v_int&&v_signed_char" | |
142 | ||
143 | gdb_test "print v_int && v_unsigned_char" " = $true" \ | |
144 | "print value of v_int&&v_unsigned_char" | |
145 | ||
146 | gdb_test "print v_int && v_signed_short" " = $true" \ | |
147 | "print value of v_int&&v_signed_short" | |
148 | ||
149 | gdb_test "print v_int && v_unsigned_short" " = $true" \ | |
150 | "print value of v_int&&v_unsigned_short" | |
151 | ||
152 | gdb_test "print v_int && v_signed_int" " = $true" \ | |
153 | "print value of v_int&&v_signed_int" | |
154 | ||
155 | gdb_test "print v_int && v_unsigned_int" " = $true" \ | |
156 | "print value of v_int&&v_unsigned_int" | |
157 | ||
158 | gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long" | |
159 | ||
160 | gdb_test "print v_int && v_signed_long" " = $true" \ | |
161 | "print value of v_int&&v_signed_long" | |
162 | ||
163 | gdb_test "print v_int && v_unsigned_long" " = $false" \ | |
164 | "print value of v_int&&v_unsigned_long" | |
165 | ||
166 | gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float" | |
167 | ||
168 | gdb_test "print v_int && v_double" " = $false" \ | |
169 | "print value of v_int&&v_double" | |
c906108c SS |
170 | |
171 | ||
172 | ||
173 | ||
174 |