Commit | Line | Data |
---|---|---|
c8f91604 AB |
1 | # Copyright 2019 Free Software Foundation, Inc. |
2 | ||
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This file tests GDB's handling of some of the builtin logical and | |
17 | # arithmetic dot operators in Fortran, for example `.AND.` and `.LE.`. | |
18 | ||
19 | load_lib "fortran.exp" | |
20 | ||
21 | if { [skip_fortran_tests] } { continue } | |
22 | ||
23 | proc test_dot_operations {} { | |
24 | ||
25 | foreach_with_prefix format { "uppercase" "lowercase" } { | |
26 | if {$format == "uppercase"} { | |
27 | set true ".TRUE." | |
28 | set false ".FALSE." | |
29 | set and ".AND." | |
30 | set or ".OR." | |
31 | set not ".NOT." | |
32 | set eqv ".EQV." | |
33 | set neqv ".NEQV." | |
34 | set eq ".EQ." | |
35 | set ne ".NE." | |
36 | set le ".LE." | |
37 | set ge ".GE." | |
38 | set lt ".LT." | |
39 | set gt ".GT." | |
40 | } else { | |
41 | set true ".true." | |
42 | set false ".false." | |
43 | set and ".and." | |
44 | set or ".or." | |
45 | set not ".not." | |
46 | set eqv ".eqv." | |
47 | set neqv ".neqv." | |
48 | set eq ".eq." | |
49 | set ne ".ne." | |
50 | set le ".le." | |
51 | set ge ".ge." | |
52 | set lt ".lt." | |
53 | set gt ".gt." | |
54 | } | |
55 | ||
56 | # Logical AND | |
57 | gdb_test "p $true $and $true" " = .TRUE." | |
58 | gdb_test "p $true $and $false" " = .FALSE." | |
59 | gdb_test "p $false $and $true" " = .FALSE." | |
60 | gdb_test "p $false $and $false" " = .FALSE." | |
61 | ||
62 | # Logical OR | |
63 | gdb_test "p $true $or $true" " = .TRUE." | |
64 | gdb_test "p $true $or $false" " = .TRUE." | |
65 | gdb_test "p $false $or $true" " = .TRUE." | |
66 | gdb_test "p $false $or $false" " = .FALSE." | |
67 | ||
68 | # Logical NOT | |
69 | gdb_test "p $not $true" " = .FALSE." | |
70 | gdb_test "p $not $false" " = .TRUE." | |
71 | ||
72 | # Logical EQV | |
73 | gdb_test "p $true $eqv $true" " = .TRUE." | |
74 | gdb_test "p $true $eqv $false" " = .FALSE." | |
75 | gdb_test "p $false $eqv $true" " = .FALSE." | |
76 | gdb_test "p $false $eqv $false" " = .TRUE." | |
77 | ||
78 | # Logical NEQV | |
79 | gdb_test "p $true $neqv $true" " = .FALSE." | |
80 | gdb_test "p $true $neqv $false" " = .TRUE." | |
81 | gdb_test "p $false $neqv $true" " = .TRUE." | |
82 | gdb_test "p $false $neqv $false" " = .FALSE." | |
83 | ||
84 | # Arithmetic EQ | |
85 | gdb_test "p 5 $eq 4" " = .FALSE." | |
86 | gdb_test "p 4 $eq 4" " = .TRUE." | |
87 | ||
88 | # Arithmetic NE | |
89 | gdb_test "p 5 $ne 4" " = .TRUE." | |
90 | gdb_test "p 4 $ne 4" " = .FALSE." | |
91 | ||
92 | # Arithmetic LE | |
93 | gdb_test "p 5 $le 4" " = .FALSE." | |
94 | gdb_test "p 4 $le 4" " = .TRUE." | |
95 | gdb_test "p 3 $le 4" " = .TRUE." | |
96 | ||
97 | # Arithmetic LT | |
98 | gdb_test "p 5 $lt 4" " = .FALSE." | |
99 | gdb_test "p 4 $lt 4" " = .FALSE." | |
100 | gdb_test "p 3 $lt 4" " = .TRUE." | |
101 | ||
102 | # Arithmetic GE | |
103 | gdb_test "p 5 $ge 4" " = .TRUE." | |
104 | gdb_test "p 4 $ge 4" " = .TRUE." | |
105 | gdb_test "p 3 $ge 4" " = .FALSE." | |
106 | ||
107 | # Arithmetic GT | |
108 | gdb_test "p 5 $gt 4" " = .TRUE." | |
109 | gdb_test "p 4 $gt 4" " = .FALSE." | |
110 | gdb_test "p 3 $gt 4" " = .FALSE." | |
111 | } | |
112 | } | |
113 | ||
114 | # Start of test script. | |
115 | ||
116 | clean_restart | |
117 | ||
118 | if [set_lang_fortran] then { | |
119 | test_dot_operations | |
120 | } else { | |
121 | warning "$test_name tests suppressed." 0 | |
122 | } | |
123 |