Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright 1998-2018 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 | # | |
21 | # test of evaluation of conditional expressions, with constants and | |
22 | # variables. Using the print and the whatis command | |
23 | # written with the only purpose in mind to cover the holes in the | |
24 | # eval.c file | |
25 | # | |
26 | # source file "int-type.c" | |
27 | # | |
28 | ||
29 | ||
c906108c SS |
30 | # Check to see if we have an executable to test. If not, then either we |
31 | # haven't tried to compile one, or the compilation failed for some reason. | |
32 | # In either case, just notify the user and skip the tests in this file. | |
33 | ||
f76495c8 TT |
34 | standard_testfile int-type.c |
35 | ||
fc91c6c2 | 36 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { |
5b362f04 | 37 | untested "failed to compile" |
b60f0898 | 38 | return -1 |
c906108c SS |
39 | } |
40 | ||
41 | ||
f76495c8 | 42 | clean_restart ${binfile} |
c906108c SS |
43 | |
44 | ||
45 | if ![runto_main] then { | |
46 | perror "couldn't run to breakpoint" | |
47 | continue | |
48 | } | |
49 | ||
ad3986f0 MS |
50 | gdb_test "print (2 ? 3 : 4)" "\[0-9\]* = 3" \ |
51 | "print value of cond expr (const true)" | |
52 | ||
53 | gdb_test "print (0 ? 3 : 4)" "\[0-9\]* = 4" \ | |
54 | "print value of cond expr (const false)" | |
c906108c | 55 | |
27d3a1a2 MS |
56 | gdb_test_no_output "set variable x=14" "set variable x=14" |
57 | gdb_test_no_output "set variable y=2" "set variable y=2" | |
58 | gdb_test_no_output "set variable z=3" "set variable z=3" | |
c906108c | 59 | |
ad3986f0 MS |
60 | gdb_test "print (x ? y : z)" "\[0-9\]* = 2" \ |
61 | "print value of cond expr (var true)" | |
c906108c | 62 | |
27d3a1a2 | 63 | gdb_test_no_output "set variable x=0" "set variable x=0" |
c906108c | 64 | |
ad3986f0 MS |
65 | gdb_test "print (x ? y : z)" "\[0-9\]* = 3" \ |
66 | "print value of cond expr (var false)" | |
67 | ||
68 | gdb_test "whatis (0 ? 3 : 4)" "type = int" \ | |
69 | "print whatis of cond expr" | |
c906108c SS |
70 | |
71 | ||
72 | ||
73 | ||
74 | ||
75 | ||
76 | ||
77 | ||
78 | ||
79 | ||
80 |