1 |
330 |
jeremybenn |
# Copyright 1998, 1999, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
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
|
5 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
6 |
|
|
# (at your option) any later version.
|
7 |
|
|
#
|
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.
|
12 |
|
|
#
|
13 |
|
|
# You should have received a copy of the GNU General Public License
|
14 |
|
|
# along with this program. If not, see .
|
15 |
|
|
|
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 |
|
|
#
|
31 |
|
|
|
32 |
|
|
if { [prepare_for_testing relational.exp relational int-type.c {debug nowarnings}] } {
|
33 |
|
|
return -1
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
if [get_compiler_info not-used] {
|
37 |
|
|
return -1;
|
38 |
|
|
}
|
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 |
|
|
#
|
50 |
|
|
# test expressions with "int" types
|
51 |
|
|
#
|
52 |
|
|
|
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"
|
57 |
|
|
|
58 |
|
|
gdb_test "print x" " = 14" "print value of x"
|
59 |
|
|
|
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
|
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"
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
# Test associativity of <, >, <=, >=, ==, !=
|
80 |
|
|
|
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"
|
84 |
|
|
|
85 |
|
|
gdb_test "print x < y < z" "$true" "print value of x
|
86 |
|
|
|
87 |
|
|
gdb_test "print x <= y <= z" "$true" "print value of x<=y<=z"
|
88 |
|
|
|
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"
|
92 |
|
|
|
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"
|
96 |
|
|
|
97 |
|
|
gdb_test "print x == y == z" "$true" "print value of x==y==z"
|
98 |
|
|
|
99 |
|
|
gdb_test_no_output "set variable z=0" "set variable z"
|
100 |
|
|
|
101 |
|
|
gdb_test "print x != y != z" "$false" "print value of x!=y!=z"
|
102 |
|
|
|
103 |
|
|
# test precedence rules on pairs of relational operators
|
104 |
|
|
|
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"
|
108 |
|
|
|
109 |
|
|
gdb_test "print x < y == z" "$false" "print value of x
|
110 |
|
|
|
111 |
|
|
# 0 2 2
|
112 |
|
|
gdb_test "print x < y != z" "$true" "print value of x
|
113 |
|
|
|
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"
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
# 2 3 1
|
120 |
|
|
gdb_test "print x < y <= z" "$true" "print value of x
|
121 |
|
|
|
122 |
|
|
# 2 3 1
|
123 |
|
|
gdb_test "print x < y >= z" "$true" "print value of x=z"
|
124 |
|
|
|
125 |
|
|
gdb_test_no_output "set variable z=0" " set variable z"
|
126 |
|
|
|
127 |
|
|
# 2 3 0
|
128 |
|
|
gdb_test "print x < y > z" "$true" "print value of xz"
|
129 |
|
|
|
130 |
|
|
gdb_test_no_output "set variable x=1" " set variable x"
|
131 |
|
|
|
132 |
|
|
# 1 3 0
|
133 |
|
|
gdb_test "print x > y >= z" "$true" "print value of x>y>=z"
|
134 |
|
|
|
135 |
|
|
gdb_test_no_output "set variable z=2" " set variable z"
|
136 |
|
|
|
137 |
|
|
# 1 3 2
|
138 |
|
|
gdb_test "print x > y == z" "$false" "print value of x>y==z"
|
139 |
|
|
|
140 |
|
|
gdb_test_no_output "set variable x=2" " set variable x"
|
141 |
|
|
gdb_test_no_output "set variable z=0" " set variable z"
|
142 |
|
|
|
143 |
|
|
# 2 3 0
|
144 |
|
|
gdb_test "print x > y != z" "$false" "print value of x>y!=z"
|
145 |
|
|
|
146 |
|
|
gdb_test_no_output "set variable x=4" "set x to 4"
|
147 |
|
|
|
148 |
|
|
# 4 3 0
|
149 |
|
|
gdb_test "print x > y <= z" "$false" "print value of x>y<=z"
|
150 |
|
|
|
151 |
|
|
# 4 3 0
|
152 |
|
|
gdb_test "print x >= y == z" "$false" "print value of x>=y==z"
|
153 |
|
|
|
154 |
|
|
gdb_test_no_output "set variable x=2" " set variable x"
|
155 |
|
|
|
156 |
|
|
# 2 3 0
|
157 |
|
|
gdb_test "print x >= y != z" "$false" "print value of x>=y!=z"
|
158 |
|
|
|
159 |
|
|
gdb_test_no_output "set variable x=0" " set variable x"
|
160 |
|
|
gdb_test_no_output "set variable z=4" " set variable z"
|
161 |
|
|
|
162 |
|
|
# 0 3 4
|
163 |
|
|
gdb_test "print x >= y <= z" "$true" "print value of x>=y<=z"
|
164 |
|
|
|
165 |
|
|
# 0 3 4
|
166 |
|
|
gdb_test "print x <= y == z" "$false" "print value of x<=y==z"
|
167 |
|
|
|
168 |
|
|
gdb_test_no_output "set variable x=2" " set variable x"
|
169 |
|
|
|
170 |
|
|
# 2 3 4
|
171 |
|
|
gdb_test "print x <= y != z" "$true" "print value of x<=y!=z"
|
172 |
|
|
|
173 |
|
|
# 2 3 4
|
174 |
|
|
gdb_test "print x == y != z" "$true" "print value of x==y!=z"
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
# test use of parenthesis to enforce different order of evaluation
|
179 |
|
|
|
180 |
|
|
gdb_test_no_output "set variable z=0" " set variable z"
|
181 |
|
|
|
182 |
|
|
# 2 3 0
|
183 |
|
|
gdb_test "print x >= (y < z)" "$true" "print value of x>=(y
|
184 |
|
|
|
185 |
|
|
# 2 3 0
|
186 |
|
|
gdb_test "print x >= (y != z)" "$true" "print value of x>=(y!=z)"
|
187 |
|
|
|
188 |
|
|
# 2 3 0
|
189 |
|
|
gdb_test "print x == (y == z)" "$false" "print value of x==(y==z)"
|
190 |
|
|
|
191 |
|
|
gdb_test_no_output "set variable x=1" " set variable x"
|
192 |
|
|
gdb_test_no_output "set variable z=4" " set variable z"
|
193 |
|
|
|
194 |
|
|
# 1 3 4
|
195 |
|
|
gdb_test "print (x == y) < z" "$true" "print value of (x==y)
|
196 |
|
|
|