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