1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
# Copyright 1998-2015 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
# This file is part of the gdb testsuite
#
# tests for arithmetic, logical and relational operators
# with mixed types
#
#
# test running programs
#
standard_testfile all-types.c
if [get_compiler_info] {
return -1
}
if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
untested $testfile.exp
return -1
}
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
gdb_test "next" "return 0;" "continuing after dummy()"
gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char"
gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short"
gdb_test "print v_int+v_signed_char" " = 72" \
"print value of v_int+v_signed_char"
gdb_test "print v_int+v_unsigned_char" " = 73" \
"print value of v_int+v_unsigned_char"
gdb_test "print v_int+v_signed_short" " = 10" \
"print value of v_int+v_signed_short"
gdb_test "print v_int+v_unsigned_short" " = 11" \
"print value of v_int+v_unsigned_short"
gdb_test "print v_int+v_signed_int" " = 13" \
"print value of v_int+v_signed_int"
gdb_test "print v_int+v_unsigned_int" " = 14" \
"print value of v_int+v_unsigned_int"
gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long"
gdb_test "print v_int+v_signed_long" " = 16" \
"print value of v_int+v_signed_long"
gdb_test "print v_int+v_unsigned_long" " = 17" \
"print value of v_int+v_unsigned_long"
gdb_test "print v_int+v_float" " = 106.34343.*" \
"print value of v_int+v_float"
gdb_test "print v_int+v_double" " = 206.565.*" \
"print value of v_int+v_double"
#
# test the relational operators with mixed types
#
gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char"
gdb_test "print v_int <= v_short" " = $false" \
"print value of v_int<=v_short"
gdb_test "print v_int <= v_signed_char" " = 1" \
"print value of v_int<=v_signed_char"
gdb_test "print v_int <= v_unsigned_char" " = 1" \
"print value of v_int<=v_unsigned_char"
gdb_test "print v_int <= v_signed_short" " = $false" \
"print value of v_int<=v_signed_short"
gdb_test "print v_int <= v_unsigned_short" " = $false" \
"print value of v_int<=v_unsigned_short"
gdb_test "print v_int <= v_signed_int" " = $true" \
"print value of v_int<=v_signed_int"
gdb_test "print v_int <= v_unsigned_int" " = $true" \
"print value of v_int<=v_unsigned_int"
gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long"
gdb_test "print v_int <= v_signed_long" " = $true" \
"print value of v_int<=v_signed_long"
gdb_test "print v_int <= v_unsigned_long" " = $true" \
"print value of v_int<=v_unsigned_long"
gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float"
gdb_test "print v_int <= v_double" " = $true" \
"print value of v_int<=v_double"
#
# test the logical operators with mixed types
#
gdb_test_no_output "set variable v_char=0" "set v_char=0"
gdb_test_no_output "set variable v_double=0.0" "set v_double=0"
gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0"
gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char"
gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short"
gdb_test "print v_int && v_signed_char" " = $true" \
"print value of v_int&&v_signed_char"
gdb_test "print v_int && v_unsigned_char" " = $true" \
"print value of v_int&&v_unsigned_char"
gdb_test "print v_int && v_signed_short" " = $true" \
"print value of v_int&&v_signed_short"
gdb_test "print v_int && v_unsigned_short" " = $true" \
"print value of v_int&&v_unsigned_short"
gdb_test "print v_int && v_signed_int" " = $true" \
"print value of v_int&&v_signed_int"
gdb_test "print v_int && v_unsigned_int" " = $true" \
"print value of v_int&&v_unsigned_int"
gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long"
gdb_test "print v_int && v_signed_long" " = $true" \
"print value of v_int&&v_signed_long"
gdb_test "print v_int && v_unsigned_long" " = $false" \
"print value of v_int&&v_unsigned_long"
gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float"
gdb_test "print v_int && v_double" " = $false" \
"print value of v_int&&v_double"
|