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