blob: ed40bdcda0cfd566d0c0083e5cd29d6cb8edc3b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# Copyright 2007-2018 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
load_lib "pascal.exp"
standard_testfile .pas
if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
untested "failed to compile"
return -1
}
clean_restart ${testfile}
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
pass "setting breakpoint 1"
}
if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
pass "setting breakpoint 2"
}
# Verify that "start" lands inside the right procedure.
if { [gdb_start_cmd] < 0 } {
untested start
return -1
}
gdb_test "" ".* at .*${srcfile}.*" "start"
gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint"
gdb_test "print r" ".* = 0" "print r before assigned to 1.25"
gdb_test "next" "r := 1\\.25;" "next to 'r := 1.25' line"
gdb_test "next" "s := 2\\.2;" "next to 's := 2.2' line"
gdb_test "next" "t := -3\\.2;" "next to 't := -3.2' line"
gdb_test "next" "u := 78\\.3;" "next to 'u := 78.3' line"
gdb_test "next" "l := 1;" "next to 'l := 1' line"
gdb_test "next" "i := 1;" "next to 'i := 1' line"
# At that point,
# r should be equal to 1.25
gdb_test "print r" " = 1\\.25"
# s should be equal to 2.2
gdb_test "print s" " = 2\\.(199.*|2|200.*)"
# t should be equal to -3.2
gdb_test "print t" " = -3\\.(199.*|2|200.*)"
# u should be equal to 78.3
gdb_test "print u" " = 78\\.(3|300.*|299.*)"
# Test addition
gdb_test "print r + s" " = 3\\.4(499.*|5|500.*)"
gdb_test "print r + t" " = -1\\.9(499.*|5|500.*)"
#Test addition with float constants
gdb_test "print r + 1.5" " = 2\\.7(499.*|5|500.*)"
gdb_test "print r + 0.03" " = 1\\.2(799.*|8|800.*)"
gdb_test "print r + (-0.2)" " = 1\\.0(499.*|5|500.*)"
gdb_test "print r + 1.5E+3" " = 1501\\.2(499.*|5|500.*)"
gdb_test "print r + 1.5E+2" " = 151\\.2(499.*|5|500.*)"
gdb_test "print r + 1.5E+1" " = 16\\.2(499.*|5|500.*)"
gdb_test "print r + 1.5E+0" " = 2\\.7(499.*|5|500.*)"
gdb_test "print r + 1.5E-1" " = 1\\.(399.*|4|400.*)"
gdb_test "print r + 1.5E-2" " = 1\\.26(499.*|5|500.*)"
gdb_test "print r + 1.5E-3" " = 1\\.251(499.*|5|500.*)"
# Test addition with integer variables
gdb_test "print r + l" " = 2\\.2(499.*|5|500.*)"
gdb_test "print l + t" " = -2\\.(199.*|2|200.*)"
# Test addition with integer constants
gdb_test "print r + 10" " = 11\\.2(499.*|5|500.*)"
gdb_test "print r + 5" " = 6\\.2(499.*|5|500.*)"
gdb_test "print r + 1" " = 2\\.2(499.*|5|500.*)"
gdb_test "print r + 0" " = 1\\.2(499.*|5|500.*)"
gdb_test "print r + (-1)" " = 0\\.2(499.*|5|500.*)"
gdb_test "print r + (-5)" " = -3\\.7(499.*|5|500.*)"
gdb_test "print r + (-10)" " = -8\\.7(499.*|5|500.*)"
# Test substraction
gdb_test "print r - s" " = -0\\.9(499.*|5|500.*)"
gdb_test "print r - t" " = 4\\.4(499.*|5|500.*)"
# Test unany minus
gdb_test "print -r" " = -1\\.2(499.*|5|500.*)"
gdb_test "print (-r)" " = -1\\.2(499.*|5|500.*)"
gdb_test "print -(r)" " = -1.2(499.*|5|500.*)"
gdb_test "print -(r + s)" " = -3\\.4(499.*|5|500.*)"
# Test multiplication
gdb_test "print 2 * r" " = 2\\.(499.*|5|500.*)"
gdb_test "print 2.0 * r" " = 2\\.(499.*|5|500.*)"
gdb_test "print 1000*r" " = 12(49\\.99.*|50|50\\.00.*)"
#Test division
gdb_test "print r / 2" " = 0\\.62(499.*|5|500.*)"
gdb_test "print 35 / 2" " = 17\\.(499.*|5|500.*)"
# 'set r' does not work, as there are set sub-commands starting with 'r'
# Thus we need to use 'set var r'
gdb_test "set var r := 2.56" " := 2\\.56"
gdb_test "print r" " = 2\\.5(599.*|6|600.*)" "testing new r value"
gdb_test "cont" \
"Breakpoint .*:${bp_location2}.*" \
"Going to second breakpoint"
gdb_test "next" "r := cos\\(u\\);" "advance to 'r := cos(u)' line"
gdb_test "print u" " = 3\\.14159.*" "test pi value"
gdb_test "next" "s := sin\\(u\\);" "advance to 's := sin(u)' line"
gdb_test "print r" " = -1" "test cos(pi) is equal to -1"
gdb_test "next" "" "go past 's := sin(u)' line"
set msg "Test sin(pi) is equal to 0"
gdb_test_multiple "print s" $msg {
-re ".* = (0|-?\[0-9\]\\.\[0-9\]*\[eE\](-?\[0-9\]*))\[\r\n\]+$gdb_prompt $" {
set value "$expect_out(1,string)"
verbose "value is $value" 1
if [info exists expect_out(2,string)] {
set expo $expect_out(2,string)
verbose "expo found: $expo" 1
} else {
set expo "0"
regsub ".*\[eE\]" "$value" "" expo
}
regsub "^-" "$expo" "" mexpo
verbose "expo is $expo" 1
verbose "mexpo is $mexpo" 1
if { $value == 0 } {
pass $msg
} elseif {$mexpo > 8} {
pass "$msg '$value' is close to zero"
} else {
fail "$msg '$value' too large"
}
verbose "Still here" 1
}
}
|