revert previous patch
[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
27d3a1a2
MS
53gdb_test_no_output "set variable x=14" "set variable x=14"
54gdb_test_no_output "set variable y=2" "set variable y=2"
55gdb_test_no_output "set variable z=2" "set variable z=2"
56gdb_test_no_output "set variable w=3" "set variable w=3"
c906108c 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
27d3a1a2
MS
81gdb_test_no_output "set variable x=3" "set variable x"
82gdb_test_no_output "set variable y=5" "set variable y"
83gdb_test_no_output "set variable z=2" "set variable z"
c906108c 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 92
27d3a1a2
MS
93gdb_test_no_output "set variable x=2" "set variable x"
94gdb_test_no_output "set variable y=2" "set variable y"
95gdb_test_no_output "set variable z=1" "set variable z"
c906108c 96
02746bbc 97gdb_test "print x == y == z" "$true" "print value of x==y==z"
c906108c 98
27d3a1a2 99gdb_test_no_output "set variable z=0" "set variable z"
c906108c 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
27d3a1a2
MS
105gdb_test_no_output "set variable x=0" "set variable x"
106gdb_test_no_output "set variable y=2" "set variable y"
107gdb_test_no_output "set variable z=2" "set variable z"
c906108c 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 113
27d3a1a2
MS
114gdb_test_no_output "set variable x=2" "set variable x"
115gdb_test_no_output "set variable y=3" "set variable y"
116gdb_test_no_output "set variable z=1" "set variable z"
c906108c
SS
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 124
27d3a1a2 125gdb_test_no_output "set variable z=0" " set variable z"
c906108c 126
c906108c 127# 2 3 0
02746bbc 128gdb_test "print x < y > z" "$true" "print value of x<y>z"
c906108c 129
27d3a1a2 130gdb_test_no_output "set variable x=1" " set variable x"
c906108c
SS
131
132# 1 3 0
02746bbc 133gdb_test "print x > y >= z" "$true" "print value of x>y>=z"
c906108c 134
27d3a1a2 135gdb_test_no_output "set variable z=2" " set variable z"
c906108c
SS
136
137# 1 3 2
02746bbc 138gdb_test "print x > y == z" "$false" "print value of x>y==z"
c906108c 139
27d3a1a2
MS
140gdb_test_no_output "set variable x=2" " set variable x"
141gdb_test_no_output "set variable z=0" " set variable z"
c906108c
SS
142
143# 2 3 0
02746bbc 144gdb_test "print x > y != z" "$false" "print value of x>y!=z"
c906108c 145
27d3a1a2 146gdb_test_no_output "set variable x=4" "set x to 4"
c906108c
SS
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 153
27d3a1a2 154gdb_test_no_output "set variable x=2" " set variable x"
c906108c
SS
155
156# 2 3 0
02746bbc 157gdb_test "print x >= y != z" "$false" "print value of x>=y!=z"
c906108c 158
27d3a1a2
MS
159gdb_test_no_output "set variable x=0" " set variable x"
160gdb_test_no_output "set variable z=4" " set variable z"
c906108c
SS
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 167
27d3a1a2 168gdb_test_no_output "set variable x=2" " set variable x"
c906108c
SS
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 179
27d3a1a2 180gdb_test_no_output "set variable z=0" " set variable z"
c906108c
SS
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 190
27d3a1a2
MS
191gdb_test_no_output "set variable x=1" " set variable x"
192gdb_test_no_output "set variable z=4" " set variable z"
c906108c
SS
193
194# 1 3 4
02746bbc 195gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z"
c906108c 196
This page took 1.053661 seconds and 4 git commands to generate.