1 # Copyright
2022-2023 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # Test the detection and printing of repeated elements in Fortran arrays.
18 require allow_fortran_tests
22 # Build up the expected output
for each array.
23 set a9p9o
"(9, 9, 9, 9, 9, 9)"
24 set a1p
"(1, 1, 1, 1, 1)"
25 set a1p9
"(1, 1, 1, 1, 1, 9)"
26 set a2po
"(2, 2, 2, 2, 2)"
27 set a2p
"(${a2po} ${a2po} ${a2po} ${a2po} ${a2po})"
28 set a2p9o
"(2, 2, 2, 2, 2, 9)"
29 set a2p9
"(${a2p9o} ${a2p9o} ${a2p9o} ${a2p9o} ${a2p9o} ${a9p9o})"
30 set a3po
"(3, 3, 3, 3, 3)"
31 set a3p
"(${a3po} ${a3po} ${a3po} ${a3po} ${a3po})"
32 set a3p
"(${a3p} ${a3p} ${a3p} ${a3p} ${a3p})"
33 set a3p9o
"(3, 3, 3, 3, 3, 9)"
34 set a3p9
"(${a3p9o} ${a3p9o} ${a3p9o} ${a3p9o} ${a3p9o} ${a9p9o})"
35 set a9p9
"(${a9p9o} ${a9p9o} ${a9p9o} ${a9p9o} ${a9p9o} ${a9p9o})"
36 set a3p9
"(${a3p9} ${a3p9} ${a3p9} ${a3p9} ${a3p9} ${a9p9})"
38 #
Convert the output into a regexp.
39 set r1p
[string_to_regexp $a1p
]
40 set r1p9
[string_to_regexp $a1p9
]
41 set r2po
[string_to_regexp $a2po
]
42 set r2p9o
[string_to_regexp $a2p9o
]
43 set r2p
[string_to_regexp $a2p
]
44 set r2p9
[string_to_regexp $a2p9
]
45 set r3po
[string_to_regexp $a3po
]
46 set r3p9o
[string_to_regexp $a3p9o
]
47 set r3p
[string_to_regexp $a3p
]
48 set r3p9
[string_to_regexp $a3p9
]
50 set rep5
"<repeats 5 times>"
51 set rep6
"<repeats 6 times>"
53 proc array_repeat
{ variant
} {
54 global testfile srcfile binfile
55 upvar r1p r1p r1p9 r1p9 r2po r2po r2p9o r2p9o r2p r2p r2p9 r2p9
56 upvar r3po r3po r3p9o r3p9o r3p r3p r3p9 r3p9
57 upvar a2po a2po a2p9o a2p9o a3po a3po a3p9o a3p9o
58 upvar rep5 rep5 rep6 rep6
60 standard_testfile
"${variant}.f90"
62 if {[prepare_for_testing $
{testfile
}.exp $
{variant
} $
{srcfile
} \
67 if {![fortran_runto_main
]} {
68 perror
"Could not run to main."
72 gdb_breakpoint
[gdb_get_line_number
"Break here"]
73 gdb_continue_to_breakpoint
"${variant}"
75 with_test_prefix
"${variant}: repeats=unlimited, elements=unlimited" {
76 # Check the arrays print as expected.
77 gdb_test_no_output
"set print repeats unlimited"
78 gdb_test_no_output
"set print elements unlimited"
80 gdb_test
"print array_1d" "${r1p}"
81 gdb_test
"print array_1d9" "${r1p9}"
82 gdb_test
"print array_2d" "${r2p}"
83 gdb_test
"print array_2d9" "${r2p9}"
84 gdb_test
"print array_3d" "${r3p}"
85 gdb_test
"print array_3d9" "${r3p9}"
88 with_test_prefix
"${variant}: repeats=4, elements=unlimited" {
89 # Now
set the repeat
limit.
90 gdb_test_no_output
"set print repeats 4"
91 gdb_test_no_output
"set print elements unlimited"
93 gdb_test
"print array_1d" \
94 [string_to_regexp
"(1, ${rep5})"]
95 gdb_test
"print array_1d9" \
96 [string_to_regexp
"(1, ${rep5}, 9)"]
97 gdb_test
"print array_2d" \
98 [string_to_regexp
"((2, ${rep5}) ${rep5})"]
99 gdb_test
"print array_2d9" \
100 [string_to_regexp
"((2, ${rep5}, 9) ${rep5} (9, ${rep6}))"]
101 gdb_test
"print array_3d" \
102 [string_to_regexp
"(((3, ${rep5}) ${rep5}) ${rep5})"]
103 gdb_test
"print array_3d9" \
104 [string_to_regexp
"(((3, ${rep5}, 9) ${rep5} (9, ${rep6})) ${rep5}\
105 ((9, $
{rep6
}) $
{rep6
}))"]
108 with_test_prefix
"${variant}: repeats=unlimited, elements=12" {
109 # Now
set the element
limit.
110 gdb_test_no_output
"set print repeats unlimited"
111 gdb_test_no_output
"set print elements 12"
113 gdb_test
"print array_1d" "${r1p}"
114 gdb_test
"print array_1d9" "${r1p9}"
115 gdb_test
"print array_2d" \
116 [string_to_regexp
"(${a2po} ${a2po} (2, 2, ...) ...)"]
117 gdb_test
"print array_2d9" \
118 [string_to_regexp
"(${a2p9o} ${a2p9o} ...)"]
119 gdb_test
"print array_3d" \
120 [string_to_regexp
"((${a3po} ${a3po} (3, 3, ...) ...) ...)"]
121 gdb_test
"print array_3d9" \
122 [string_to_regexp
"((${a3p9o} ${a3p9o} ...) ...)"]
125 with_test_prefix
"${variant}: repeats=4, elements=12" {
126 # Now
set both limits.
127 gdb_test_no_output
"set print repeats 4"
128 gdb_test_no_output
"set print elements 12"
130 gdb_test
"print array_1d" \
131 [string_to_regexp
"(1, ${rep5})"]
132 gdb_test
"print array_1d9" \
133 [string_to_regexp
"(1, ${rep5}, 9)"]
134 gdb_test
"print array_2d" \
135 [string_to_regexp
"((2, ${rep5}) (2, ${rep5}) (2, 2, ...) ...)"]
136 gdb_test
"print array_2d9" \
137 [string_to_regexp
"((2, ${rep5}, 9) (2, ${rep5}, 9) ...)"]
138 gdb_test
"print array_3d" \
139 [string_to_regexp
"(((3, ${rep5}) (3, ${rep5}) (3, 3, ...) ...)\
141 gdb_test
"print array_3d9" \
142 [string_to_regexp
"(((3, ${rep5}, 9) (3, ${rep5}, 9) ...) ...)"]
145 with_test_prefix
"${variant}: repeats=4, elements=30" {
146 # Now
set both limits.
147 gdb_test_no_output
"set print repeats 4"
148 gdb_test_no_output
"set print elements 30"
150 gdb_test
"print array_1d" \
151 [string_to_regexp
"(1, ${rep5})"]
152 gdb_test
"print array_1d9" \
153 [string_to_regexp
"(1, ${rep5}, 9)"]
154 gdb_test
"print array_2d" \
155 [string_to_regexp
"((2, ${rep5}) ${rep5})"]
156 gdb_test
"print array_2d9" \
157 [string_to_regexp
"((2, ${rep5}, 9) ${rep5} ...)"]
158 gdb_test
"print array_3d" \
159 [string_to_regexp
"(((3, ${rep5}) ${rep5}) ((3, ${rep5}) ...)\
161 gdb_test
"print array_3d9" \
162 [string_to_regexp
"(((3, ${rep5}, 9) ${rep5} ...) ...)"]
166 array_repeat
"array-repeat"
167 array_repeat
"array-slices-repeat"