Fix for PR gdb/1543.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.pascal / integers.exp
CommitLineData
2d8fd90a
PM
1# Copyright 2008 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
16if $tracelevel then {
17 strace $tracelevel
18}
19
20load_lib "pascal.exp"
21
22set testfile "integers"
23set srcfile ${testfile}.pas
24set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
25
26if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
27 return -1
28}
29
30gdb_exit
31gdb_start
32gdb_reinitialize_dir $srcdir/$subdir
33gdb_load ${binfile}
34set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
35set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
36
37if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
38 pass "setting breakpoint 1"
39}
40if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
41 pass "setting breakpoint 2"
42}
43
44# Verify that "start" lands inside the right procedure.
45if { [gdb_start_cmd] < 0 } {
46 untested start
47 return -1
48}
49
50gdb_test "" ".* at .*${srcfile}.*" "start"
51
52gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
53
54gdb_test "print i" ".* = 0" "Print i before assigned to 1"
55
56gdb_test "next" "i := 1;" "Next to 'i := 1' line"
57gdb_test "next" "j := 2;" "Next to 'j := 2' line"
58# At that point,
59# i should be equal to 1
60gdb_test "print i" " = 1"
61# but j should still be equal to zero
62if { $pascal_compiler_is_gpc } {
63 setup_xfail *-*-*
64}
65gdb_test "print j" " = 0" "Test j value before assignment"
66
67gdb_test "next" "k := 3;" "Next to 'k := 3' line"
68gdb_test "next" "l := k;" "Next to 'l := k' line"
69
70#j should be equal to 2
71gdb_test "print j" " = 2"
72# k should be equal to 3
73gdb_test "print k" " = 3"
74# But l shoud still be zero
75if { $pascal_compiler_is_gpc } {
76 setup_xfail *-*-*
77}
78gdb_test "print l" " = 0"
79
80# Test addition
81gdb_test "print i + j" " = 3"
82gdb_test "print i + k" " = 4"
83gdb_test "print j + k" " = 5"
84gdb_test "print i + j + k" " = 6"
85
86# Test substraction
87gdb_test "print j - i" " = 1"
88gdb_test "print i - j" "= -1"
89gdb_test "print k -i -j" " = 0"
90gdb_test "print k -(i + j)" " = 0"
91
92# Test unany minus
93gdb_test "print -i" " = -1"
94gdb_test "print (-i)" " = -1"
95gdb_test "print -(i)" " = -1"
96gdb_test "print -(i+j)" " = -3"
97
98# Test boolean operators =, <>, <, <=, > and >=
99gdb_test "print i + 1 = j" " = true"
100gdb_test "print i + 1 <> j" " = false"
101gdb_test "print i + 1 < j" " = false"
102gdb_test "print i + 1 <= j" " = true"
103gdb_test "print i + 1 > j" " = false"
104gdb_test "print i + 1 >= j" " = true"
105
106# Test multiplication
107gdb_test "print 2 * i" " = 2"
108gdb_test "print j * k" " = 6"
109gdb_test "print 3000*i" " = 3000"
110
111#Test div and mod operators
112gdb_test "print 35 div 2" " = 17"
113gdb_test "print 35 mod 2" " = 1"
114
115# Test several operators together
116gdb_test "print i+10*j+100*k" " = 321"
117gdb_test " print (i + 5) * (j + 7)" " = 54"
118
119# 'set i' does not work, as there are set sub-commands starting with 'i'
120# Thus we need to use 'set var i'
121gdb_test "set var i := 2" " := 2"
122gdb_test "print i" " = 2" "Testing new i value"
123
124gdb_test "cont" \
125 "Breakpoint .*:${bp_location2}.*" \
126 "Going to second breakpoint"
127gdb_test "print i" \
128 ".* = 5.*" \
129 "Value of i after assignment"
This page took 0.07317 seconds and 4 git commands to generate.