Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2008-2020 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 |
16 | load_lib "pascal.exp" |
17 | ||
17b77626 | 18 | standard_testfile .pas |
2d8fd90a PM |
19 | |
20 | if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { | |
21 | return -1 | |
22 | } | |
23 | ||
17b77626 | 24 | clean_restart ${testfile} |
2d8fd90a PM |
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 | ||
cdc7edd7 | 43 | gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint" |
2d8fd90a | 44 | |
cdc7edd7 | 45 | gdb_test "print i" ".* = 0" "print i before assigned to 1" |
2d8fd90a | 46 | |
cdc7edd7 LM |
47 | gdb_test "next" "i := 1;" "next to 'i := 1' line" |
48 | gdb_test "next" "j := 2;" "next to 'j := 2' line" | |
2d8fd90a PM |
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 | } | |
cdc7edd7 | 56 | gdb_test "print j" " = 0" "test j value before assignment" |
2d8fd90a | 57 | |
cdc7edd7 LM |
58 | gdb_test "next" "k := 3;" "next to 'k := 3' line" |
59 | gdb_test "next" "l := k;" "next to 'l := k' line" | |
2d8fd90a PM |
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" | |
cdc7edd7 | 113 | gdb_test "print i" " = 2" "testing new i value" |
2d8fd90a PM |
114 | |
115 | gdb_test "cont" \ | |
116 | "Breakpoint .*:${bp_location2}.*" \ | |
117 | "Going to second breakpoint" | |
118 | gdb_test "print i" \ | |
119 | ".* = 5.*" \ | |
bb95117e | 120 | "value of i after assignment" |