binutils-gdb/gdb/testsuite/gdb.fortran/dot-ops.exp
Andrew Burgess c8f9160408 gdb/fortran: Simplify handling of Fortran dot operations and keywords
Use strncasecmp to compare Fortran dot operations (like .AND.) and for
the keywords list.  This allows for some duplication to be removed
from the token arrays.  I've also performed whitespace cleanup around
the code I've changed.

I have added some tests to ensure that upper and lowercase dot
operations are correctly tested.  The keywords list remains always
lowercase for now.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* f-exp.y (struct token): Add comments.
	(dot_ops): Remove uppercase versions and the end marker.
	(f77_keywords): Likewise.
	(yylex): Use ARRAY_SIZE to iterate over dot_ops, assert all
	entries in the dot_ops array are case insensitive, and use
	strncasecmp to compare strings.  Also some whitespace cleanup in
	this area.  Similar for the f77_keywords array, except entries in
	this list might be case sensitive.

gdb/testsuite/ChangeLog:

	* gdb.fortran/dot-ops.exp: New file.
2019-03-06 18:11:31 +00:00

124 lines
3.2 KiB
Plaintext

# Copyright 2019 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/>.
# This file tests GDB's handling of some of the builtin logical and
# arithmetic dot operators in Fortran, for example `.AND.` and `.LE.`.
load_lib "fortran.exp"
if { [skip_fortran_tests] } { continue }
proc test_dot_operations {} {
foreach_with_prefix format { "uppercase" "lowercase" } {
if {$format == "uppercase"} {
set true ".TRUE."
set false ".FALSE."
set and ".AND."
set or ".OR."
set not ".NOT."
set eqv ".EQV."
set neqv ".NEQV."
set eq ".EQ."
set ne ".NE."
set le ".LE."
set ge ".GE."
set lt ".LT."
set gt ".GT."
} else {
set true ".true."
set false ".false."
set and ".and."
set or ".or."
set not ".not."
set eqv ".eqv."
set neqv ".neqv."
set eq ".eq."
set ne ".ne."
set le ".le."
set ge ".ge."
set lt ".lt."
set gt ".gt."
}
# Logical AND
gdb_test "p $true $and $true" " = .TRUE."
gdb_test "p $true $and $false" " = .FALSE."
gdb_test "p $false $and $true" " = .FALSE."
gdb_test "p $false $and $false" " = .FALSE."
# Logical OR
gdb_test "p $true $or $true" " = .TRUE."
gdb_test "p $true $or $false" " = .TRUE."
gdb_test "p $false $or $true" " = .TRUE."
gdb_test "p $false $or $false" " = .FALSE."
# Logical NOT
gdb_test "p $not $true" " = .FALSE."
gdb_test "p $not $false" " = .TRUE."
# Logical EQV
gdb_test "p $true $eqv $true" " = .TRUE."
gdb_test "p $true $eqv $false" " = .FALSE."
gdb_test "p $false $eqv $true" " = .FALSE."
gdb_test "p $false $eqv $false" " = .TRUE."
# Logical NEQV
gdb_test "p $true $neqv $true" " = .FALSE."
gdb_test "p $true $neqv $false" " = .TRUE."
gdb_test "p $false $neqv $true" " = .TRUE."
gdb_test "p $false $neqv $false" " = .FALSE."
# Arithmetic EQ
gdb_test "p 5 $eq 4" " = .FALSE."
gdb_test "p 4 $eq 4" " = .TRUE."
# Arithmetic NE
gdb_test "p 5 $ne 4" " = .TRUE."
gdb_test "p 4 $ne 4" " = .FALSE."
# Arithmetic LE
gdb_test "p 5 $le 4" " = .FALSE."
gdb_test "p 4 $le 4" " = .TRUE."
gdb_test "p 3 $le 4" " = .TRUE."
# Arithmetic LT
gdb_test "p 5 $lt 4" " = .FALSE."
gdb_test "p 4 $lt 4" " = .FALSE."
gdb_test "p 3 $lt 4" " = .TRUE."
# Arithmetic GE
gdb_test "p 5 $ge 4" " = .TRUE."
gdb_test "p 4 $ge 4" " = .TRUE."
gdb_test "p 3 $ge 4" " = .FALSE."
# Arithmetic GT
gdb_test "p 5 $gt 4" " = .TRUE."
gdb_test "p 4 $gt 4" " = .FALSE."
gdb_test "p 3 $gt 4" " = .FALSE."
}
}
# Start of test script.
clean_restart
if [set_lang_fortran] then {
test_dot_operations
} else {
warning "$test_name tests suppressed." 0
}