Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 1998, 1999, 2007, 2008, 2009, 2010 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 correctenss of relational operators, associativity and precedence | |
21 | # with integer type variables | |
22 | # | |
23 | ||
24 | if $tracelevel then { | |
25 | strace $tracelevel | |
26 | } | |
27 | ||
28 | # | |
29 | # test running programs | |
30 | # | |
c906108c | 31 | |
aa81e255 JK |
32 | if { [prepare_for_testing relational.exp relational int-type.c {debug nowarnings}] } { |
33 | return -1 | |
34 | } | |
c906108c | 35 | |
aa81e255 | 36 | if [get_compiler_info not-used] { |
085dd6e6 JM |
37 | return -1; |
38 | } | |
c906108c | 39 | |
c906108c SS |
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 | # | |
50 | # test expressions with "int" types | |
51 | # | |
52 | ||
27d3a1a2 MS |
53 | gdb_test_no_output "set variable x=14" "set variable x=14" |
54 | gdb_test_no_output "set variable y=2" "set variable y=2" | |
55 | gdb_test_no_output "set variable z=2" "set variable z=2" | |
56 | gdb_test_no_output "set variable w=3" "set variable w=3" | |
c906108c | 57 | |
02746bbc | 58 | gdb_test "print x" " = 14" "print value of x" |
c906108c | 59 | |
02746bbc MS |
60 | gdb_test "print y" " = 2" "print value of y" |
61 | ||
62 | gdb_test "print z" " = 2" "print value of z" | |
63 | ||
64 | gdb_test "print w" " = 3" "print value of w" | |
65 | ||
66 | gdb_test "print x < y" "$false" "print value of x<y" | |
67 | ||
68 | gdb_test "print x <= y" "$false" "print value of x<=y" | |
69 | ||
70 | gdb_test "print x > y" "$true" "print value of x>y" | |
71 | ||
72 | gdb_test "print x >= y" "$true" "print value of x>=y" | |
73 | ||
74 | gdb_test "print x == y" "$false" "print value of x==y" | |
75 | ||
76 | gdb_test "print x != y" "$true" "print value of x!=y" | |
c906108c SS |
77 | |
78 | ||
79 | # Test associativity of <, >, <=, >=, ==, != | |
80 | ||
27d3a1a2 MS |
81 | gdb_test_no_output "set variable x=3" "set variable x" |
82 | gdb_test_no_output "set variable y=5" "set variable y" | |
83 | gdb_test_no_output "set variable z=2" "set variable z" | |
c906108c | 84 | |
02746bbc | 85 | gdb_test "print x < y < z" "$true" "print value of x<y<z" |
c906108c | 86 | |
02746bbc | 87 | gdb_test "print x <= y <= z" "$true" "print value of x<=y<=z" |
c906108c | 88 | |
02746bbc MS |
89 | gdb_test "print x > y > z" "$false" "print value of x>y>z" |
90 | ||
91 | gdb_test "print x >= y >= z" "$false" "print value of x>=y>=z" | |
c906108c | 92 | |
27d3a1a2 MS |
93 | gdb_test_no_output "set variable x=2" "set variable x" |
94 | gdb_test_no_output "set variable y=2" "set variable y" | |
95 | gdb_test_no_output "set variable z=1" "set variable z" | |
c906108c | 96 | |
02746bbc | 97 | gdb_test "print x == y == z" "$true" "print value of x==y==z" |
c906108c | 98 | |
27d3a1a2 | 99 | gdb_test_no_output "set variable z=0" "set variable z" |
c906108c | 100 | |
02746bbc | 101 | gdb_test "print x != y != z" "$false" "print value of x!=y!=z" |
c906108c SS |
102 | |
103 | # test precedence rules on pairs of relational operators | |
104 | ||
27d3a1a2 MS |
105 | gdb_test_no_output "set variable x=0" "set variable x" |
106 | gdb_test_no_output "set variable y=2" "set variable y" | |
107 | gdb_test_no_output "set variable z=2" "set variable z" | |
c906108c | 108 | |
02746bbc | 109 | gdb_test "print x < y == z" "$false" "print value of x<y==z" |
c906108c SS |
110 | |
111 | # 0 2 2 | |
02746bbc | 112 | gdb_test "print x < y != z" "$true" "print value of x<y!=z" |
c906108c | 113 | |
27d3a1a2 MS |
114 | gdb_test_no_output "set variable x=2" "set variable x" |
115 | gdb_test_no_output "set variable y=3" "set variable y" | |
116 | gdb_test_no_output "set variable z=1" "set variable z" | |
c906108c SS |
117 | |
118 | ||
119 | # 2 3 1 | |
02746bbc | 120 | gdb_test "print x < y <= z" "$true" "print value of x<y<=z" |
c906108c SS |
121 | |
122 | # 2 3 1 | |
02746bbc | 123 | gdb_test "print x < y >= z" "$true" "print value of x<y>=z" |
c906108c | 124 | |
27d3a1a2 | 125 | gdb_test_no_output "set variable z=0" " set variable z" |
c906108c | 126 | |
c906108c | 127 | # 2 3 0 |
02746bbc | 128 | gdb_test "print x < y > z" "$true" "print value of x<y>z" |
c906108c | 129 | |
27d3a1a2 | 130 | gdb_test_no_output "set variable x=1" " set variable x" |
c906108c SS |
131 | |
132 | # 1 3 0 | |
02746bbc | 133 | gdb_test "print x > y >= z" "$true" "print value of x>y>=z" |
c906108c | 134 | |
27d3a1a2 | 135 | gdb_test_no_output "set variable z=2" " set variable z" |
c906108c SS |
136 | |
137 | # 1 3 2 | |
02746bbc | 138 | gdb_test "print x > y == z" "$false" "print value of x>y==z" |
c906108c | 139 | |
27d3a1a2 MS |
140 | gdb_test_no_output "set variable x=2" " set variable x" |
141 | gdb_test_no_output "set variable z=0" " set variable z" | |
c906108c SS |
142 | |
143 | # 2 3 0 | |
02746bbc | 144 | gdb_test "print x > y != z" "$false" "print value of x>y!=z" |
c906108c | 145 | |
27d3a1a2 | 146 | gdb_test_no_output "set variable x=4" "set x to 4" |
c906108c SS |
147 | |
148 | # 4 3 0 | |
02746bbc | 149 | gdb_test "print x > y <= z" "$false" "print value of x>y<=z" |
c906108c SS |
150 | |
151 | # 4 3 0 | |
02746bbc | 152 | gdb_test "print x >= y == z" "$false" "print value of x>=y==z" |
c906108c | 153 | |
27d3a1a2 | 154 | gdb_test_no_output "set variable x=2" " set variable x" |
c906108c SS |
155 | |
156 | # 2 3 0 | |
02746bbc | 157 | gdb_test "print x >= y != z" "$false" "print value of x>=y!=z" |
c906108c | 158 | |
27d3a1a2 MS |
159 | gdb_test_no_output "set variable x=0" " set variable x" |
160 | gdb_test_no_output "set variable z=4" " set variable z" | |
c906108c SS |
161 | |
162 | # 0 3 4 | |
02746bbc | 163 | gdb_test "print x >= y <= z" "$true" "print value of x>=y<=z" |
c906108c SS |
164 | |
165 | # 0 3 4 | |
02746bbc | 166 | gdb_test "print x <= y == z" "$false" "print value of x<=y==z" |
c906108c | 167 | |
27d3a1a2 | 168 | gdb_test_no_output "set variable x=2" " set variable x" |
c906108c SS |
169 | |
170 | # 2 3 4 | |
02746bbc | 171 | gdb_test "print x <= y != z" "$true" "print value of x<=y!=z" |
c906108c SS |
172 | |
173 | # 2 3 4 | |
02746bbc | 174 | gdb_test "print x == y != z" "$true" "print value of x==y!=z" |
c906108c | 175 | |
c906108c | 176 | |
c906108c | 177 | |
02746bbc | 178 | # test use of parenthesis to enforce different order of evaluation |
c906108c | 179 | |
27d3a1a2 | 180 | gdb_test_no_output "set variable z=0" " set variable z" |
c906108c SS |
181 | |
182 | # 2 3 0 | |
02746bbc | 183 | gdb_test "print x >= (y < z)" "$true" "print value of x>=(y<z)" |
c906108c SS |
184 | |
185 | # 2 3 0 | |
02746bbc | 186 | gdb_test "print x >= (y != z)" "$true" "print value of x>=(y!=z)" |
c906108c SS |
187 | |
188 | # 2 3 0 | |
02746bbc | 189 | gdb_test "print x == (y == z)" "$false" "print value of x==(y==z)" |
c906108c | 190 | |
27d3a1a2 MS |
191 | gdb_test_no_output "set variable x=1" " set variable x" |
192 | gdb_test_no_output "set variable z=4" " set variable z" | |
c906108c SS |
193 | |
194 | # 1 3 4 | |
02746bbc | 195 | gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z" |
c906108c | 196 |