]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.pascal/integers.exp
* elfxx-tilegx.c (tilegx_elf_relocate_section): Silence bogus warning.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.pascal / integers.exp
1 # Copyright 2008-2012 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 load_lib "pascal.exp"
17
18 set testfile "integers"
19 set srcfile ${testfile}.pas
20 set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
21
22 if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
23 return -1
24 }
25
26 gdb_exit
27 gdb_start
28 gdb_reinitialize_dir $srcdir/$subdir
29 gdb_load ${binfile}
30 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
31 set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
32
33 if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
34 pass "setting breakpoint 1"
35 }
36 if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
37 pass "setting breakpoint 2"
38 }
39
40 # Verify that "start" lands inside the right procedure.
41 if { [gdb_start_cmd] < 0 } {
42 untested start
43 return -1
44 }
45
46 gdb_test "" ".* at .*${srcfile}.*" "start"
47
48 gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
49
50 gdb_test "print i" ".* = 0" "Print i before assigned to 1"
51
52 gdb_test "next" "i := 1;" "Next to 'i := 1' line"
53 gdb_test "next" "j := 2;" "Next to 'j := 2' line"
54 # At that point,
55 # i should be equal to 1
56 gdb_test "print i" " = 1"
57 # but j should still be equal to zero
58 if { $pascal_compiler_is_gpc } {
59 setup_xfail *-*-*
60 }
61 gdb_test "print j" " = 0" "Test j value before assignment"
62
63 gdb_test "next" "k := 3;" "Next to 'k := 3' line"
64 gdb_test "next" "l := k;" "Next to 'l := k' line"
65
66 #j should be equal to 2
67 gdb_test "print j" " = 2"
68 # k should be equal to 3
69 gdb_test "print k" " = 3"
70 # But l shoud still be zero
71 if { $pascal_compiler_is_gpc } {
72 setup_xfail *-*-*
73 }
74 gdb_test "print l" " = 0"
75
76 # Test addition
77 gdb_test "print i + j" " = 3"
78 gdb_test "print i + k" " = 4"
79 gdb_test "print j + k" " = 5"
80 gdb_test "print i + j + k" " = 6"
81
82 # Test substraction
83 gdb_test "print j - i" " = 1"
84 gdb_test "print i - j" "= -1"
85 gdb_test "print k -i -j" " = 0"
86 gdb_test "print k -(i + j)" " = 0"
87
88 # Test unany minus
89 gdb_test "print -i" " = -1"
90 gdb_test "print (-i)" " = -1"
91 gdb_test "print -(i)" " = -1"
92 gdb_test "print -(i+j)" " = -3"
93
94 # Test boolean operators =, <>, <, <=, > and >=
95 gdb_test "print i + 1 = j" " = true"
96 gdb_test "print i + 1 <> j" " = false"
97 gdb_test "print i + 1 < j" " = false"
98 gdb_test "print i + 1 <= j" " = true"
99 gdb_test "print i + 1 > j" " = false"
100 gdb_test "print i + 1 >= j" " = true"
101
102 # Test multiplication
103 gdb_test "print 2 * i" " = 2"
104 gdb_test "print j * k" " = 6"
105 gdb_test "print 3000*i" " = 3000"
106
107 #Test div and mod operators
108 gdb_test "print 35 div 2" " = 17"
109 gdb_test "print 35 mod 2" " = 1"
110
111 # Test several operators together
112 gdb_test "print i+10*j+100*k" " = 321"
113 gdb_test " print (i + 5) * (j + 7)" " = 54"
114
115 # 'set i' does not work, as there are set sub-commands starting with 'i'
116 # Thus we need to use 'set var i'
117 gdb_test "set var i := 2" " := 2"
118 gdb_test "print i" " = 2" "Testing new i value"
119
120 gdb_test "cont" \
121 "Breakpoint .*:${bp_location2}.*" \
122 "Going to second breakpoint"
123 gdb_test "print i" \
124 ".* = 5.*" \
125 "Value of i after assignment"