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