blob: 6b46b1c555af0a5775e0fe46f4d559edf8315c1d [file] [log] [blame]
# Copyright 2023-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/>.
gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_noarg {} {
incr ::count
return 1
}
gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg { arg } {
incr ::count
return $arg
}
gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg_nested { arg } {
incr ::count
return [gdb_testsuite_gdb_caching_proc_exp_arg $arg]
}
# List of "expected $::count after running expression" and
# "expression".
set assertions {
1 { [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 }
1 { [gdb_testsuite_gdb_caching_proc_exp_arg 1] == 1 }
1 { [gdb_testsuite_gdb_caching_proc_exp_arg "foo foo"] == "foo foo" }
1 { [gdb_testsuite_gdb_caching_proc_exp_arg_nested "foo foo"] == "foo foo" }
2 { [gdb_testsuite_gdb_caching_proc_exp_arg_nested "bar bar"] == "bar bar" }
}
set assertion_nr 0
foreach {expected_count assertion} $assertions {
with_test_prefix $assertion_nr {
set ::count 0
gdb_assert $assertion
gdb_assert { $::count == $expected_count }
with_test_prefix cached {
gdb_assert $assertion
gdb_assert { $::count == $expected_count }
}
}
incr assertion_nr
}