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