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