aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran/dot-ops.exp
blob: 787471db918932b098e1cf78b5aeda26469749d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 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
}