]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.pascal/integers.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.pascal / integers.exp
1 # Copyright 2008-2024 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 standard_testfile .pas
19
20 if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
21 return -1
22 }
23
24 clean_restart ${testfile}
25
26 if { ![runto_main] } {
27 return
28 }
29
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 gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint"
41
42 gdb_test "print i" ".* = 0" "print i before assigned to 1"
43
44 gdb_test "next" "i := 1;" "next to 'i := 1' line"
45 gdb_test "next" "j := 2;" "next to 'j := 2' line"
46 # At that point,
47 # i should be equal to 1
48 gdb_test "print i" " = 1"
49 # but j should still be equal to zero
50 if { $pascal_compiler_is_gpc } {
51 setup_xfail *-*-*
52 }
53 gdb_test "print j" " = 0" "test j value before assignment"
54
55 gdb_test "next" "k := 3;" "next to 'k := 3' line"
56 gdb_test "next" "l := k;" "next to 'l := k' line"
57
58 #j should be equal to 2
59 gdb_test "print j" " = 2"
60 # k should be equal to 3
61 gdb_test "print k" " = 3"
62 # But l shoud still be zero
63 if { $pascal_compiler_is_gpc } {
64 setup_xfail *-*-*
65 }
66 gdb_test "print l" " = 0"
67
68 # Test addition
69 gdb_test "print i + j" " = 3"
70 gdb_test "print i + k" " = 4"
71 gdb_test "print j + k" " = 5"
72 gdb_test "print i + j + k" " = 6"
73
74 # Test substraction
75 gdb_test "print j - i" " = 1"
76 gdb_test "print i - j" "= -1"
77 gdb_test "print k -i -j" " = 0"
78 gdb_test "print k -(i + j)" " = 0"
79
80 # Test unany minus
81 gdb_test "print -i" " = -1"
82 gdb_test "print (-i)" " = -1"
83 gdb_test "print -(i)" " = -1"
84 gdb_test "print -(i+j)" " = -3"
85
86 # Test boolean operators =, <>, <, <=, > and >=
87 gdb_test "print i + 1 = j" " = true"
88 gdb_test "print i + 1 <> j" " = false"
89 gdb_test "print i + 1 < j" " = false"
90 gdb_test "print i + 1 <= j" " = true"
91 gdb_test "print i + 1 > j" " = false"
92 gdb_test "print i + 1 >= j" " = true"
93
94 # Test multiplication
95 gdb_test "print 2 * i" " = 2"
96 gdb_test "print j * k" " = 6"
97 gdb_test "print 3000*i" " = 3000"
98
99 #Test div and mod operators
100 gdb_test "print 35 div 2" " = 17"
101 gdb_test "print 35 mod 2" " = 1"
102
103 # Test several operators together
104 gdb_test "print i+10*j+100*k" " = 321"
105 gdb_test " print (i + 5) * (j + 7)" " = 54"
106
107 # 'set i' does not work, as there are set sub-commands starting with 'i'
108 # Thus we need to use 'set var i'
109 gdb_test "set var i := 2" " := 2"
110 gdb_test "print i" " = 2" "testing new i value"
111
112 gdb_test "cont" \
113 "Breakpoint .*:${bp_location2}.*" \
114 "Going to second breakpoint"
115 gdb_test "print i" \
116 ".* = 5.*" \
117 "value of i after assignment"