Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Add tests for Ada "in" operator
Date: Fri, 29 May 2026 14:22:23 -0600	[thread overview]
Message-ID: <20260529202223.4130030-1-tromey@adacore.com> (raw)

Coverage testing showed that there were no existing tests of the Ada
"in" operator.  This patch adds tests for this.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34041
---
 gdb/testsuite/gdb.ada/range.exp      | 70 ++++++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/range/prog.adb | 29 ++++++++++++
 2 files changed, 99 insertions(+)
 create mode 100644 gdb/testsuite/gdb.ada/range.exp
 create mode 100644 gdb/testsuite/gdb.ada/range/prog.adb

diff --git a/gdb/testsuite/gdb.ada/range.exp b/gdb/testsuite/gdb.ada/range.exp
new file mode 100644
index 00000000000..370f2fdcc85
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/range.exp
@@ -0,0 +1,70 @@
+# Copyright 2026 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/>.
+
+# Simple tests of the 'abs' operator.
+
+load_lib "ada.exp"
+
+require allow_ada_tests
+
+standard_ada_testfile prog
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+    return
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "START" ${testdir}/prog.adb]
+if {![runto "prog.adb:$bp_location"]} {
+    return
+}
+
+set is_true [quotemeta {$@DECIMAL = true}]
+set is_false [quotemeta {$@DECIMAL = false}]
+
+proc check_true {var expr} {
+    gdb_test "print $var in $expr" $::is_true
+    gdb_test "print $var not in $expr" $::is_false
+}
+
+proc check_false {var expr} {
+    gdb_test "print $var in $expr" $::is_false
+    gdb_test "print $var not in $expr" $::is_true
+}
+
+check_true se smaller_enum
+check_true se classic_enum
+check_false ce smaller_enum
+check_true ce classic_enum
+
+check_true gamma smaller_enum
+check_true gamma classic_enum
+check_false alpha smaller_enum
+check_true alpha classic_enum
+
+check_true gamma "alpha .. epsilon"
+check_false gamma "alpha .. beta"
+check_false alpha "gamma .. epsilon"
+
+check_true beta "a'range"
+check_false alpha "a'range"
+check_false epsilon "a'range"
+check_true beta "a'range(1)"
+check_false alpha "a'range(1)"
+check_false epsilon "a'range(1)"
+check_true beta "a'range(2)"
+check_true alpha "a'range(2)"
+check_true epsilon "a'range(2)"
diff --git a/gdb/testsuite/gdb.ada/range/prog.adb b/gdb/testsuite/gdb.ada/range/prog.adb
new file mode 100644
index 00000000000..7b095a5bf36
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/range/prog.adb
@@ -0,0 +1,29 @@
+--  Copyright 2026 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/>.
+
+procedure Prog is
+   type Classic_Enum is (Alpha, Beta, Gamma, Epsilon);
+   subtype Smaller_Enum is Classic_Enum range Beta .. Gamma;
+
+   type A_T is array (Smaller_Enum, Classic_Enum) of Integer;
+
+   SE : Smaller_Enum := Gamma;
+   CE : Classic_Enum := Epsilon;
+
+   A : A_T := (others => (others => 0));
+
+begin
+   null;                        --  START
+end Prog;

base-commit: 742a479fc38a2b119d74a0bac270489911a1fd6c
-- 
2.54.0


             reply	other threads:[~2026-05-29 20:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 20:22 Tom Tromey [this message]
2026-06-12 15:21 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260529202223.4130030-1-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox