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