| # Copyright 2021-2025 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 "ada.exp" | 
 |  | 
 | require allow_ada_tests | 
 |  | 
 | standard_ada_testfile opcall | 
 |  | 
 | if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { | 
 |     return | 
 | } | 
 |  | 
 | clean_restart ${testfile} | 
 |  | 
 | set bp_location [gdb_get_line_number "STOP" ${testdir}/opcall.adb] | 
 | runto "opcall.adb:$bp_location" | 
 |  | 
 | gdb_test "print p" " = \\(x => 4, y => 5\\)" | 
 |  | 
 | proc test_with_menu {command result} { | 
 |     global expect_out | 
 |  | 
 |     set rxcmd [string_to_regexp $command] | 
 |  | 
 |     set num {} | 
 |     send_gdb "$command\n" | 
 |     gdb_expect 30 { | 
 | 	-re "^$rxcmd\r\n" { | 
 | 	    exp_continue | 
 | 	} | 
 | 	-re "Multiple matches for \[^\r\n\]*\r\n" { | 
 | 	    exp_continue | 
 | 	} | 
 | 	-re "^\\\[(\[0-9\]+)\\\] twovecs\\.*\[^\r\n\]*\r\n" { | 
 | 	    set num $expect_out(1,string) | 
 | 	    exp_continue | 
 | 	} | 
 | 	-re "^\\\[\[0-9\]+\\\] \[^\r\n\]*\r\n" { | 
 | 	    # Any other match, we don't want. | 
 | 	    exp_continue | 
 | 	} | 
 | 	-re "^> " { | 
 | 	    if {$num == ""} { | 
 | 		fail $command | 
 | 		set num 0 | 
 | 	    } | 
 | 	    send_gdb "$num\n" | 
 | 	    exp_continue | 
 | 	} | 
 | 	-re "^\[0-9\]+\r\n" { | 
 | 	    # The number we just sent, ignore. | 
 | 	    exp_continue | 
 | 	} | 
 | 	-re "\\\$\[0-9\]+ = (\[^\r\n\]+)\r\n" { | 
 | 	    if {[regexp $result $expect_out(1,string)]} { | 
 | 		pass $command | 
 | 	    } else { | 
 | 		fail $command | 
 | 	    } | 
 | 	} | 
 | 	"Argument to arithmetic operation not a number or boolean." { | 
 | 	    fail $command | 
 | 	} | 
 | 	-re "No definition of \".*\" in current context." { | 
 | 	    fail $command | 
 | 	} | 
 | 	timeout { | 
 | 	    fail "$command (timeout)" | 
 | 	} | 
 |     } | 
 | } | 
 |  | 
 | test_with_menu "print p + p" "\\(x => 8, y => 10\\)" | 
 | test_with_menu "print p - p" "\\(x => 0, y => 0\\)" | 
 | test_with_menu "print p * p" "\\(x => 16, y => 25\\)" | 
 | test_with_menu "print p / p" "\\(x => 1, y => 1\\)" | 
 |  | 
 | # See the code to understand the weird numbers here. | 
 | test_with_menu "print p mod p" "\\(x => 17, y => 18\\)" | 
 | test_with_menu "print p rem p" "\\(x => 38, y => 39\\)" | 
 | test_with_menu "print p ** p" "\\(x => 84, y => 105\\)" | 
 |  | 
 | test_with_menu "print p < p" "false" | 
 | test_with_menu "print p < p2" "true" | 
 | test_with_menu "print p <= p" "true" | 
 | test_with_menu "print p <= p2" "true" | 
 | test_with_menu "print p > p" "false" | 
 | test_with_menu "print p2 > p" "true" | 
 | test_with_menu "print p >= p" "true" | 
 | test_with_menu "print p2 >= p" "true" | 
 | test_with_menu "print p = p" "true" | 
 | test_with_menu "print p = p2" "false" | 
 | test_with_menu "print p /= p" "false" | 
 | test_with_menu "print p /= p2" "true" | 
 |  | 
 | test_with_menu "print p and p2" "\\(x => 4, y => 4\\)" | 
 | test_with_menu "print p or p2" "\\(x => 12, y => 13\\)" | 
 | test_with_menu "print p xor p2" "\\(x => 8, y => 9\\)" | 
 |  | 
 | # See the code to understand the weird numbers here. | 
 | test_with_menu "print p & p" "\\(x => 44, y => 55\\)" | 
 |  | 
 | test_with_menu "print -p" "\\(x => 65532, y => 65531\\)" | 
 | test_with_menu "print abs(-p)" "\\(x => 65532, y => 65531\\)" | 
 | test_with_menu "print not(p)" "\\(x => 65531, y => 65530\\)" | 
 |  | 
 | # See the code to understand the weird numbers here. | 
 | test_with_menu "print +(p)" "\\(x => 5, y => 4\\)" |