]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - 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
1 # Copyright 2008-2013 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 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
26 set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
27
28 if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
29 pass "setting breakpoint 1"
30 }
31 if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
32 pass "setting breakpoint 2"
33 }
34
35 # Verify that "start" lands inside the right procedure.
36 if { [gdb_start_cmd] < 0 } {
37 untested start
38 return -1
39 }
40
41 gdb_test "" ".* at .*${srcfile}.*" "start"
42
43 gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
44
45 gdb_test "print i" ".* = 0" "Print i before assigned to 1"
46
47 gdb_test "next" "i := 1;" "Next to 'i := 1' line"
48 gdb_test "next" "j := 2;" "Next to 'j := 2' line"
49 # At that point,
50 # i should be equal to 1
51 gdb_test "print i" " = 1"
52 # but j should still be equal to zero
53 if { $pascal_compiler_is_gpc } {
54 setup_xfail *-*-*
55 }
56 gdb_test "print j" " = 0" "Test j value before assignment"
57
58 gdb_test "next" "k := 3;" "Next to 'k := 3' line"
59 gdb_test "next" "l := k;" "Next to 'l := k' line"
60
61 #j should be equal to 2
62 gdb_test "print j" " = 2"
63 # k should be equal to 3
64 gdb_test "print k" " = 3"
65 # But l shoud still be zero
66 if { $pascal_compiler_is_gpc } {
67 setup_xfail *-*-*
68 }
69 gdb_test "print l" " = 0"
70
71 # Test addition
72 gdb_test "print i + j" " = 3"
73 gdb_test "print i + k" " = 4"
74 gdb_test "print j + k" " = 5"
75 gdb_test "print i + j + k" " = 6"
76
77 # Test substraction
78 gdb_test "print j - i" " = 1"
79 gdb_test "print i - j" "= -1"
80 gdb_test "print k -i -j" " = 0"
81 gdb_test "print k -(i + j)" " = 0"
82
83 # Test unany minus
84 gdb_test "print -i" " = -1"
85 gdb_test "print (-i)" " = -1"
86 gdb_test "print -(i)" " = -1"
87 gdb_test "print -(i+j)" " = -3"
88
89 # Test boolean operators =, <>, <, <=, > and >=
90 gdb_test "print i + 1 = j" " = true"
91 gdb_test "print i + 1 <> j" " = false"
92 gdb_test "print i + 1 < j" " = false"
93 gdb_test "print i + 1 <= j" " = true"
94 gdb_test "print i + 1 > j" " = false"
95 gdb_test "print i + 1 >= j" " = true"
96
97 # Test multiplication
98 gdb_test "print 2 * i" " = 2"
99 gdb_test "print j * k" " = 6"
100 gdb_test "print 3000*i" " = 3000"
101
102 #Test div and mod operators
103 gdb_test "print 35 div 2" " = 17"
104 gdb_test "print 35 mod 2" " = 1"
105
106 # Test several operators together
107 gdb_test "print i+10*j+100*k" " = 321"
108 gdb_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'
112 gdb_test "set var i := 2" " := 2"
113 gdb_test "print i" " = 2" "Testing new i value"
114
115 gdb_test "cont" \
116 "Breakpoint .*:${bp_location2}.*" \
117 "Going to second breakpoint"
118 gdb_test "print i" \
119 ".* = 5.*" \
120 "Value of i after assignment"