]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.fortran/array-repeat.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / array-repeat.exp
CommitLineData
213516ef 1# Copyright 2022-2023 Free Software Foundation, Inc.
476f77a9
MR
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# Test the detection and printing of repeated elements in Fortran arrays.
17
18if {[skip_fortran_tests]} { return -1 }
19
20load_lib fortran.exp
21
22# Build up the expected output for each array.
23set a9p9o "(9, 9, 9, 9, 9, 9)"
24set a1p "(1, 1, 1, 1, 1)"
25set a1p9 "(1, 1, 1, 1, 1, 9)"
26set a2po "(2, 2, 2, 2, 2)"
27set a2p "(${a2po} ${a2po} ${a2po} ${a2po} ${a2po})"
28set a2p9o "(2, 2, 2, 2, 2, 9)"
29set a2p9 "(${a2p9o} ${a2p9o} ${a2p9o} ${a2p9o} ${a2p9o} ${a9p9o})"
30set a3po "(3, 3, 3, 3, 3)"
31set a3p "(${a3po} ${a3po} ${a3po} ${a3po} ${a3po})"
32set a3p "(${a3p} ${a3p} ${a3p} ${a3p} ${a3p})"
33set a3p9o "(3, 3, 3, 3, 3, 9)"
34set a3p9 "(${a3p9o} ${a3p9o} ${a3p9o} ${a3p9o} ${a3p9o} ${a9p9o})"
35set a9p9 "(${a9p9o} ${a9p9o} ${a9p9o} ${a9p9o} ${a9p9o} ${a9p9o})"
36set a3p9 "(${a3p9} ${a3p9} ${a3p9} ${a3p9} ${a3p9} ${a9p9})"
37
38# Convert the output into a regexp.
39set r1p [string_to_regexp $a1p]
40set r1p9 [string_to_regexp $a1p9]
41set r2po [string_to_regexp $a2po]
42set r2p9o [string_to_regexp $a2p9o]
43set r2p [string_to_regexp $a2p]
44set r2p9 [string_to_regexp $a2p9]
45set r3po [string_to_regexp $a3po]
46set r3p9o [string_to_regexp $a3p9o]
47set r3p [string_to_regexp $a3p]
48set r3p9 [string_to_regexp $a3p9]
49
50set rep5 "<repeats 5 times>"
51set rep6 "<repeats 6 times>"
52
53proc 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
59
60 standard_testfile "${variant}.f90"
61
62 if {[prepare_for_testing ${testfile}.exp ${variant} ${srcfile} \
63 {debug f90}]} {
64 return -1
65 }
66
67 if {![fortran_runto_main]} {
68 perror "Could not run to main."
cdd42066 69 return
476f77a9
MR
70 }
71
72 gdb_breakpoint [gdb_get_line_number "Break here"]
73 gdb_continue_to_breakpoint "${variant}"
74
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"
79
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}"
86 }
87
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"
92
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}))"]
106 }
107
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"
112
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} ...) ...)"]
123 }
124
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"
129
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, ...) ...)\
140 ...)"]
141 gdb_test "print array_3d9" \
142 [string_to_regexp "(((3, ${rep5}, 9) (3, ${rep5}, 9) ...) ...)"]
143 }
144
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"
149
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}) ...)\
160 ...)"]
161 gdb_test "print array_3d9" \
162 [string_to_regexp "(((3, ${rep5}, 9) ${rep5} ...) ...)"]
163 }
164}
165
166array_repeat "array-repeat"
167array_repeat "array-slices-repeat"