gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / relational.exp
CommitLineData
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
28if { [prepare_for_testing relational.exp relational int-type.c {debug nowarnings}] } {
29 return -1
30}
c906108c 31
4c93b1db 32if [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
40if ![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
49gdb_test_no_output "set variable x=14" "set variable x=14"
50gdb_test_no_output "set variable y=2" "set variable y=2"
51gdb_test_no_output "set variable z=2" "set variable z=2"
52gdb_test_no_output "set variable w=3" "set variable w=3"
c906108c 53
02746bbc 54gdb_test "print x" " = 14" "print value of x"
c906108c 55
02746bbc
MS
56gdb_test "print y" " = 2" "print value of y"
57
58gdb_test "print z" " = 2" "print value of z"
59
60gdb_test "print w" " = 3" "print value of w"
61
62gdb_test "print x < y" "$false" "print value of x<y"
63
64gdb_test "print x <= y" "$false" "print value of x<=y"
65
66gdb_test "print x > y" "$true" "print value of x>y"
67
68gdb_test "print x >= y" "$true" "print value of x>=y"
69
70gdb_test "print x == y" "$false" "print value of x==y"
71
72gdb_test "print x != y" "$true" "print value of x!=y"
c906108c
SS
73
74
75# Test associativity of <, >, <=, >=, ==, !=
76
27d3a1a2
MS
77gdb_test_no_output "set variable x=3" "set variable x"
78gdb_test_no_output "set variable y=5" "set variable y"
79gdb_test_no_output "set variable z=2" "set variable z"
c906108c 80
02746bbc 81gdb_test "print x < y < z" "$true" "print value of x<y<z"
c906108c 82
02746bbc 83gdb_test "print x <= y <= z" "$true" "print value of x<=y<=z"
c906108c 84
02746bbc
MS
85gdb_test "print x > y > z" "$false" "print value of x>y>z"
86
87gdb_test "print x >= y >= z" "$false" "print value of x>=y>=z"
c906108c 88
27d3a1a2
MS
89gdb_test_no_output "set variable x=2" "set variable x"
90gdb_test_no_output "set variable y=2" "set variable y"
91gdb_test_no_output "set variable z=1" "set variable z"
c906108c 92
02746bbc 93gdb_test "print x == y == z" "$true" "print value of x==y==z"
c906108c 94
27d3a1a2 95gdb_test_no_output "set variable z=0" "set variable z"
c906108c 96
02746bbc 97gdb_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
101gdb_test_no_output "set variable x=0" "set variable x"
102gdb_test_no_output "set variable y=2" "set variable y"
103gdb_test_no_output "set variable z=2" "set variable z"
c906108c 104
02746bbc 105gdb_test "print x < y == z" "$false" "print value of x<y==z"
c906108c
SS
106
107# 0 2 2
02746bbc 108gdb_test "print x < y != z" "$true" "print value of x<y!=z"
c906108c 109
27d3a1a2
MS
110gdb_test_no_output "set variable x=2" "set variable x"
111gdb_test_no_output "set variable y=3" "set variable y"
112gdb_test_no_output "set variable z=1" "set variable z"
c906108c
SS
113
114
115# 2 3 1
02746bbc 116gdb_test "print x < y <= z" "$true" "print value of x<y<=z"
c906108c
SS
117
118# 2 3 1
02746bbc 119gdb_test "print x < y >= z" "$true" "print value of x<y>=z"
c906108c 120
27d3a1a2 121gdb_test_no_output "set variable z=0" " set variable z"
c906108c 122
c906108c 123# 2 3 0
02746bbc 124gdb_test "print x < y > z" "$true" "print value of x<y>z"
c906108c 125
27d3a1a2 126gdb_test_no_output "set variable x=1" " set variable x"
c906108c
SS
127
128# 1 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 z=2" " set variable z"
c906108c
SS
132
133# 1 3 2
02746bbc 134gdb_test "print x > y == z" "$false" "print value of x>y==z"
c906108c 135
27d3a1a2
MS
136gdb_test_no_output "set variable x=2" " set variable x"
137gdb_test_no_output "set variable z=0" " set variable z"
c906108c
SS
138
139# 2 3 0
02746bbc 140gdb_test "print x > y != z" "$false" "print value of x>y!=z"
c906108c 141
27d3a1a2 142gdb_test_no_output "set variable x=4" "set x to 4"
c906108c
SS
143
144# 4 3 0
02746bbc 145gdb_test "print x > y <= z" "$false" "print value of x>y<=z"
c906108c
SS
146
147# 4 3 0
02746bbc 148gdb_test "print x >= y == z" "$false" "print value of x>=y==z"
c906108c 149
27d3a1a2 150gdb_test_no_output "set variable x=2" " set variable x"
c906108c
SS
151
152# 2 3 0
02746bbc 153gdb_test "print x >= y != z" "$false" "print value of x>=y!=z"
c906108c 154
27d3a1a2
MS
155gdb_test_no_output "set variable x=0" " set variable x"
156gdb_test_no_output "set variable z=4" " set variable z"
c906108c
SS
157
158# 0 3 4
02746bbc 159gdb_test "print x >= y <= z" "$true" "print value of x>=y<=z"
c906108c
SS
160
161# 0 3 4
02746bbc 162gdb_test "print x <= y == z" "$false" "print value of x<=y==z"
c906108c 163
27d3a1a2 164gdb_test_no_output "set variable x=2" " set variable x"
c906108c
SS
165
166# 2 3 4
02746bbc 167gdb_test "print x <= y != z" "$true" "print value of x<=y!=z"
c906108c
SS
168
169# 2 3 4
02746bbc 170gdb_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 176gdb_test_no_output "set variable z=0" " set variable z"
c906108c
SS
177
178# 2 3 0
02746bbc 179gdb_test "print x >= (y < z)" "$true" "print value of x>=(y<z)"
c906108c
SS
180
181# 2 3 0
02746bbc 182gdb_test "print x >= (y != z)" "$true" "print value of x>=(y!=z)"
c906108c
SS
183
184# 2 3 0
02746bbc 185gdb_test "print x == (y == z)" "$false" "print value of x==(y==z)"
c906108c 186
27d3a1a2
MS
187gdb_test_no_output "set variable x=1" " set variable x"
188gdb_test_no_output "set variable z=4" " set variable z"
c906108c
SS
189
190# 1 3 4
02746bbc 191gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z"
c906108c 192
This page took 1.410515 seconds and 4 git commands to generate.