2010-06-01 Rafael Espindola <espindola@google.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / relational.exp
CommitLineData
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
24if $tracelevel then {
25 strace $tracelevel
26 }
27
28#
29# test running programs
30#
c906108c 31
aa81e255
JK
32if { [prepare_for_testing relational.exp relational int-type.c {debug nowarnings}] } {
33 return -1
34}
c906108c 35
aa81e255 36if [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
44if ![runto_main] then {
45 perror "couldn't run to breakpoint"
46 continue
47}
48
49#
50# test expressions with "int" types
51#
52
53gdb_test "set variable x=14" "" "set variable x=14"
54gdb_test "set variable y=2" "" "set variable y=2"
55gdb_test "set variable z=2" "" "set variable z=2"
56gdb_test "set variable w=3" "" "set variable w=3"
57
02746bbc 58gdb_test "print x" " = 14" "print value of x"
c906108c 59
02746bbc
MS
60gdb_test "print y" " = 2" "print value of y"
61
62gdb_test "print z" " = 2" "print value of z"
63
64gdb_test "print w" " = 3" "print value of w"
65
66gdb_test "print x < y" "$false" "print value of x<y"
67
68gdb_test "print x <= y" "$false" "print value of x<=y"
69
70gdb_test "print x > y" "$true" "print value of x>y"
71
72gdb_test "print x >= y" "$true" "print value of x>=y"
73
74gdb_test "print x == y" "$false" "print value of x==y"
75
76gdb_test "print x != y" "$true" "print value of x!=y"
c906108c
SS
77
78
79# Test associativity of <, >, <=, >=, ==, !=
80
81gdb_test "set variable x=3" "" "set variable x"
82gdb_test "set variable y=5" "" "set variable y"
83gdb_test "set variable z=2" "" "set variable z"
84
02746bbc 85gdb_test "print x < y < z" "$true" "print value of x<y<z"
c906108c 86
02746bbc 87gdb_test "print x <= y <= z" "$true" "print value of x<=y<=z"
c906108c 88
02746bbc
MS
89gdb_test "print x > y > z" "$false" "print value of x>y>z"
90
91gdb_test "print x >= y >= z" "$false" "print value of x>=y>=z"
c906108c
SS
92
93gdb_test "set variable x=2" "" "set variable x"
94gdb_test "set variable y=2" "" "set variable y"
95gdb_test "set variable z=1" "" "set variable z"
96
02746bbc 97gdb_test "print x == y == z" "$true" "print value of x==y==z"
c906108c
SS
98
99gdb_test "set variable z=0" "" "set variable z"
100
02746bbc 101gdb_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
105gdb_test "set variable x=0" "" "set variable x"
106gdb_test "set variable y=2" "" "set variable y"
107gdb_test "set variable z=2" "" "set variable z"
108
02746bbc 109gdb_test "print x < y == z" "$false" "print value of x<y==z"
c906108c
SS
110
111# 0 2 2
02746bbc 112gdb_test "print x < y != z" "$true" "print value of x<y!=z"
c906108c
SS
113
114gdb_test "set variable x=2" "" "set variable x"
115gdb_test "set variable y=3" "" "set variable y"
116gdb_test "set variable z=1" "" "set variable z"
117
118
119# 2 3 1
02746bbc 120gdb_test "print x < y <= z" "$true" "print value of x<y<=z"
c906108c
SS
121
122# 2 3 1
02746bbc 123gdb_test "print x < y >= z" "$true" "print value of x<y>=z"
c906108c
SS
124
125gdb_test "set variable z=0" "" " set variable z"
126
c906108c 127# 2 3 0
02746bbc 128gdb_test "print x < y > z" "$true" "print value of x<y>z"
c906108c
SS
129
130gdb_test "set variable x=1" "" " set variable x"
131
132# 1 3 0
02746bbc 133gdb_test "print x > y >= z" "$true" "print value of x>y>=z"
c906108c
SS
134
135gdb_test "set variable z=2" "" " set variable z"
136
137# 1 3 2
02746bbc 138gdb_test "print x > y == z" "$false" "print value of x>y==z"
c906108c
SS
139
140gdb_test "set variable x=2" "" " set variable x"
141gdb_test "set variable z=0" "" " set variable z"
142
143# 2 3 0
02746bbc 144gdb_test "print x > y != z" "$false" "print value of x>y!=z"
c906108c
SS
145
146gdb_test "set variable x=4" "" "set x to 4"
147
148# 4 3 0
02746bbc 149gdb_test "print x > y <= z" "$false" "print value of x>y<=z"
c906108c
SS
150
151# 4 3 0
02746bbc 152gdb_test "print x >= y == z" "$false" "print value of x>=y==z"
c906108c
SS
153
154gdb_test "set variable x=2" "" " set variable x"
155
156# 2 3 0
02746bbc 157gdb_test "print x >= y != z" "$false" "print value of x>=y!=z"
c906108c
SS
158
159gdb_test "set variable x=0" "" " set variable x"
160gdb_test "set variable z=4" "" " set variable z"
161
162# 0 3 4
02746bbc 163gdb_test "print x >= y <= z" "$true" "print value of x>=y<=z"
c906108c
SS
164
165# 0 3 4
02746bbc 166gdb_test "print x <= y == z" "$false" "print value of x<=y==z"
c906108c
SS
167
168gdb_test "set variable x=2" "" " set variable x"
169
170# 2 3 4
02746bbc 171gdb_test "print x <= y != z" "$true" "print value of x<=y!=z"
c906108c
SS
172
173# 2 3 4
02746bbc 174gdb_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
SS
179
180gdb_test "set variable z=0" "" " set variable z"
181
182# 2 3 0
02746bbc 183gdb_test "print x >= (y < z)" "$true" "print value of x>=(y<z)"
c906108c
SS
184
185# 2 3 0
02746bbc 186gdb_test "print x >= (y != z)" "$true" "print value of x>=(y!=z)"
c906108c
SS
187
188# 2 3 0
02746bbc 189gdb_test "print x == (y == z)" "$false" "print value of x==(y==z)"
c906108c
SS
190
191gdb_test "set variable x=1" "" " set variable x"
192gdb_test "set variable z=4" "" " set variable z"
193
194# 1 3 4
02746bbc 195gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z"
c906108c 196
This page took 0.952262 seconds and 4 git commands to generate.