gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / bitops.exp
1 # Copyright 1998, 1999, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18
19 # This file is part of the gdb testsuite
20 #
21 # tests expressions with bitwise operators, and some
22 # logical operators
23 # Does not use a target program
24 #
25
26
27 if $tracelevel then {
28 strace $tracelevel
29 }
30
31 #
32 # test running programs
33 #
34
35
36 gdb_exit
37 gdb_start
38 gdb_reinitialize_dir $srcdir/$subdir
39
40
41 gdb_test "print !1" ".\[0-9\]* = 0" "print value of !1"
42
43 gdb_test "print !0" ".\[0-9\]* = 1" "print value of !0"
44
45 gdb_test "print !100" ".\[0-9\]* = 0" "print value of !100"
46
47 gdb_test "print !1000" ".\[0-9\]* = 0" "print value of !1000"
48
49 gdb_test "print !10" ".\[0-9\]* = 0" "print value of !10"
50
51 gdb_test "print !2" ".\[0-9\]* = 0" "print value of !2 "
52
53 gdb_test "print 10 | 5" ".\[0-9\]* = 15" "print value of 10 | 5"
54
55 gdb_test "print 10 & 5" ".\[0-9\]* = 0" "print value of 10 & 5"
56
57 gdb_test "print 10 ^ 5" ".\[0-9\]* = 15" "print value of 10 ^ 5"
58
59 gdb_test "print -!0" ".\[0-9\]* = -1" "print value of -!0"
60
61 gdb_test "print ~-!0" ".\[0-9\]* = 0" "print value of ~-!0"
62
63 gdb_test "print 3 * 2 / 4.0 * 2.0" ".\[0-9\]* = 3" \
64 "print value of 3 * 2 / 4.0 * 2.0"
65
66 gdb_test "print 8 << 2 >> 4" ".\[0-9\]* = 2" \
67 "print value of 8 << 2 >> 4"
68
69 gdb_test "print -1 < 0 > 1" ".\[0-9\]* = 0" \
70 "print value of -1 < 0 > 1"
71
72 gdb_test "print 15 ^ 10 ^ 5 ^ 7" ".\[0-9\]* = 7" \
73 "print value of 15 ^ 10 ^ 5 ^ 7"
74
75 gdb_test "print 3.5 < 4.0" ".\[0-9\]* = 1" \
76 "print value of 3.5 < 4.0"
77
78 gdb_test "print 3.5 < -4.0" ".\[0-9\]* = 0" \
79 "print value of 3.5 < -4.0"
80
81 gdb_test "print 2 > -3" ".\[0-9\]* = 1" "print value of 2 > -3"
82
83 gdb_test "print -3>4" ".\[0-9\]* = 0" "print value of -3>4"
84
85 gdb_test "print (-3 > 4)" ".\[0-9\]* = 0" "print value of (-3 > 4)"
86
87 gdb_test "print 3>=2.5" ".\[0-9\]* = 1" "print value of 3>=2.5"
88
89 gdb_test "print 3>=4.5" ".\[0-9\]* = 0" "print value of 3>=4.5"
90
91 gdb_test "print 3==3.0" ".\[0-9\]* = 1" "print value of 3==3.0"
92
93 gdb_test "print 3==4.0" ".\[0-9\]* = 0" "print value of 3==4.0"
94
95 gdb_test "print 3!=3.0" ".\[0-9\]* = 0" "print value of 3!=3.0"
96
97 gdb_test "print 3!=5.0" ".\[0-9\]* = 1" "print value of 3!=5.0"
98
99 gdb_test "print 0 || 1 && 0 | 0 ^ 0 == 8 > 128 >>1 +2 *2" \
100 ".\[0-9\]* = 0" \
101 "print value of 0 || 1 && 0 | 0 ^ 0 == 8 > 128 >>1 +2 *2"
102
103 gdb_test "print 1.0 || 0" ".\[0-9\]* = 1" \
104 "print value of 1.0 || 0"
105
106 gdb_test "print 0.0 || 1.0" ".\[0-9\]* = 1" \
107 "print value of 0.0 || 1.0"
108
109 gdb_test "print 0.0 || 0" ".\[0-9\]* = 0" \
110 "print value of 0.0 || 0"
111
112 gdb_test "print 0 || 1 && 0 | 0 ^ 0 == 8" ".\[0-9\]* = 0" \
113 "print value of 0 || 1 && 0 | 0 ^ 0 == 8"
114
115 gdb_test "print 0 == 8 > 128 >> 1 + 2 * 2" ".\[0-9\]* = 0" \
116 "print value of 0 == 8 > 128 >> 1 + 2 * 2"
117
This page took 0.031762 seconds and 4 git commands to generate.