OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.fortran/] [exprs.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright (C) 1994, 1997 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 2 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, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-gdb@prep.ai.mit.edu
19
 
20
# This file was adapted from (OBSOLETE) Chill tests by Stan Shebs (shebs@cygnus.com).
21
 
22
if $tracelevel then {
23
        strace $tracelevel
24
}
25
 
26
set prms_id 0
27
set bug_id 0
28
 
29
# Set the current language to fortran.  This counts as a test.  If it
30
# fails, then we skip the other tests.
31
 
32
proc set_lang_fortran {} {
33
    global gdb_prompt
34
 
35
    if [gdb_test "set language fortran" ""] {
36
        return 0;
37
    }
38
 
39
    if ![gdb_test "show language" ".* source language is \"fortran\".*"] {
40
        return 1;
41
    } else {
42
        return 0;
43
    }
44
}
45
 
46
proc test_integer_literals_accepted {} {
47
    global gdb_prompt
48
 
49
    # Test various decimal values.
50
 
51
    gdb_test "p 123" " = 123"
52
    gdb_test "p -123" " = -123"
53
}
54
 
55
proc test_character_literals_accepted {} {
56
    global gdb_prompt
57
 
58
    # Test various character values.
59
 
60
    gdb_test "p 'a'" " = 'a'"
61
}
62
 
63
proc test_integer_literals_rejected {} {
64
    global gdb_prompt
65
 
66
    test_print_reject "p _"
67
}
68
 
69
proc test_logical_literals_accepted {} {
70
    global gdb_prompt
71
 
72
    # Test the only possible values for a logical, TRUE and FALSE.
73
 
74
    gdb_test "p .TRUE." " = .TRUE."
75
    gdb_test "p .FALSE." " = .FALSE."
76
}
77
 
78
proc test_float_literals_accepted {} {
79
    global gdb_prompt
80
 
81
    # Test various floating point formats
82
 
83
    gdb_test "p .44 .LT. .45" " = .TRUE."
84
    gdb_test "p .44 .GT. .45" " = .FALSE."
85
    gdb_test "p 0.44 .LT. 0.45" " = .TRUE."
86
    gdb_test "p 0.44 .GT. 0.45" " = .FALSE."
87
    gdb_test "p 44. .LT. 45." " = .TRUE."
88
    gdb_test "p 44. .GT. 45." " = .FALSE."
89
    gdb_test "p 44.0 .LT. 45.0" " = .TRUE."
90
    gdb_test "p 44.0 .GT. 45.0" " = .FALSE."
91
    gdb_test "p 10D20 .LT. 10D21" " = .TRUE."
92
    gdb_test "p 10D20 .GT. 10D21" " = .FALSE."
93
    gdb_test "p 10d20 .LT. 10d21" " = .TRUE."
94
    gdb_test "p 10d20 .GT. 10d21" " = .FALSE."
95
    gdb_test "p 10E20 .LT. 10E21" " = .TRUE."
96
    gdb_test "p 10E20 .GT. 10E21" " = .FALSE."
97
    gdb_test "p 10e20 .LT. 10e21" " = .TRUE."
98
    gdb_test "p 10e20 .GT. 10e21" " = .FALSE."
99
    gdb_test "p 10.D20 .LT. 10.D21" " = .TRUE."
100
    gdb_test "p 10.D20 .GT. 10.D21" " = .FALSE."
101
    gdb_test "p 10.d20 .LT. 10.d21" " = .TRUE."
102
    gdb_test "p 10.d20 .GT. 10.d21" " = .FALSE."
103
    gdb_test "p 10.E20 .LT. 10.E21" " = .TRUE."
104
    gdb_test "p 10.E20 .GT. 10.E21" " = .FALSE."
105
    gdb_test "p 10.e20 .LT. 10.e21" " = .TRUE."
106
    gdb_test "p 10.e20 .GT. 10.e21" " = .FALSE."
107
    gdb_test "p 10.0D20 .LT. 10.0D21" " = .TRUE."
108
    gdb_test "p 10.0D20 .GT. 10.0D21" " = .FALSE."
109
    gdb_test "p 10.0d20 .LT. 10.0d21" " = .TRUE."
110
    gdb_test "p 10.0d20 .GT. 10.0d21" " = .FALSE."
111
    gdb_test "p 10.0E20 .LT. 10.0E21" " = .TRUE."
112
    gdb_test "p 10.0E20 .GT. 10.0E21" " = .FALSE."
113
    gdb_test "p 10.0e20 .LT. 10.0e21" " = .TRUE."
114
    gdb_test "p 10.0e20 .GT. 10.0e21" " = .FALSE."
115
    gdb_test "p 10.0D+20 .LT. 10.0D+21" " = .TRUE."
116
    gdb_test "p 10.0D+20 .GT. 10.0D+21" " = .FALSE."
117
    gdb_test "p 10.0d+20 .LT. 10.0d+21" " = .TRUE."
118
    gdb_test "p 10.0d+20 .GT. 10.0d+21" " = .FALSE."
119
    gdb_test "p 10.0E+20 .LT. 10.0E+21" " = .TRUE."
120
    gdb_test "p 10.0E+20 .GT. 10.0E+21" " = .FALSE."
121
    gdb_test "p 10.0e+20 .LT. 10.0e+21" " = .TRUE."
122
    gdb_test "p 10.0e+20 .GT. 10.0e+21" " = .FALSE."
123
    gdb_test "p 10.0D-11 .LT. 10.0D-10" " = .TRUE."
124
    gdb_test "p 10.0D-11 .GT. 10.0D-10" " = .FALSE."
125
    gdb_test "p 10.0d-11 .LT. 10.0d-10" " = .TRUE."
126
    gdb_test "p 10.0d-11 .GT. 10.0d-10" " = .FALSE."
127
    gdb_test "p 10.0E-11 .LT. 10.0E-10" " = .TRUE."
128
    gdb_test "p 10.0E-11 .GT. 10.0E-10" " = .FALSE."
129
    gdb_test "p 10.0e-11 .LT. 10.0e-10" " = .TRUE."
130
    gdb_test "p 10.0e-11 .GT. 10.0e-10" " = .FALSE."
131
}
132
 
133
proc test_convenience_variables {} {
134
    global gdb_prompt
135
 
136
    gdb_test "set \$foo = 101"  " = 101\[\r\n\]*" \
137
        "Set a new convenience variable"
138
 
139
    gdb_test "print \$foo"              " = 101" \
140
        "Print contents of new convenience variable"
141
 
142
    gdb_test "set \$foo = 301"  " = 301\[\r\n\]*" \
143
        "Set convenience variable to a new value"
144
 
145
    gdb_test "print \$foo"              " = 301" \
146
        "Print new contents of convenience variable"
147
 
148
    gdb_test "set \$_ = 11"             " = 11\[\r\n\]*" \
149
        "Set convenience variable \$_"
150
 
151
    gdb_test "print \$_"                " = 11" \
152
        "Print contents of convenience variable \$_"
153
 
154
    gdb_test "print \$foo + 10" " = 311" \
155
        "Use convenience variable in arithmetic expression"
156
 
157
    gdb_test "print (\$foo = 32) + 4"   " = 36" \
158
        "Use convenience variable assignment in arithmetic expression"
159
 
160
    gdb_test "print \$bar"              " = VOID" \
161
        "Print contents of uninitialized convenience variable"
162
}
163
 
164
proc test_value_history {} {
165
    global gdb_prompt
166
 
167
    gdb_test "print 101"        "\\\$1 = 101" \
168
        "Set value-history\[1\] using \$1"
169
 
170
    gdb_test "print 102"        "\\\$2 = 102" \
171
        "Set value-history\[2\] using \$2"
172
 
173
    gdb_test "print 103"        "\\\$3 = 103" \
174
        "Set value-history\[3\] using \$3"
175
 
176
    gdb_test "print \$\$"       "\\\$4 = 102" \
177
        "Print value-history\[MAX-1\] using inplicit index \$\$"
178
 
179
    gdb_test "print \$\$"       "\\\$5 = 103" \
180
        "Print value-history\[MAX-1\] again using implicit index \$\$"
181
 
182
    gdb_test "print \$" "\\\$6 = 103" \
183
        "Print value-history\[MAX\] using implicit index \$"
184
 
185
    gdb_test "print \$\$2"      "\\\$7 = 102" \
186
        "Print value-history\[MAX-2\] using explicit index \$\$2"
187
 
188
    gdb_test "print \$0"        "\\\$8 = 102" \
189
        "Print value-history\[MAX\] using explicit index \$0"
190
 
191
    gdb_test "print 108"        "\\\$9 = 108" ""
192
 
193
    gdb_test "print \$\$0"      "\\\$10 = 108" \
194
        "Print value-history\[MAX\] using explicit index \$\$0"
195
 
196
    gdb_test "print \$1"        "\\\$11 = 101" \
197
        "Print value-history\[1\] using explicit index \$1"
198
 
199
    gdb_test "print \$2"        "\\\$12 = 102" \
200
        "Print value-history\[2\] using explicit index \$2"
201
 
202
    gdb_test "print \$3"        "\\\$13 = 103" \
203
        "Print value-history\[3\] using explicit index \$3"
204
 
205
    gdb_test "print \$-3"       "\\\$14 = 100" \
206
        "Print (value-history\[MAX\] - 3) using implicit index \$"
207
 
208
    gdb_test "print \$1 + 3"    "\\\$15 = 104" \
209
        "Use value-history element in arithmetic expression"
210
}
211
 
212
proc test_arithmetic_expressions {} {
213
    global gdb_prompt
214
 
215
    # Test unary minus with various operands
216
 
217
#    gdb_test "p -(TRUE)"       " = -1" "unary minus applied to bool"
218
#    gdb_test "p -('a')"        " = xxx"        "unary minus applied to char"
219
    gdb_test "p -(1)"           " = -1" "unary minus applied to int"
220
    gdb_test "p -(1.0)" " = -1" "unary minus applied to real"
221
 
222
    # Test addition with various operands
223
 
224
    gdb_test "p .TRUE. + 1"     " = 2"  "bool plus int"
225
    gdb_test "p 1 + 1"          " = 2"  "int plus int"
226
    gdb_test "p 1.0 + 1"        " = 2"  "real plus int"
227
    gdb_test "p 1.0 + 2.0"      " = 3"  "real plus real"
228
 
229
    # Test subtraction with various operands
230
 
231
    gdb_test "p .TRUE. - 1"     " = 0"  "bool minus int"
232
    gdb_test "p 3 - 1"          " = 2"  "int minus int"
233
    gdb_test "p 3.0 - 1"        " = 2"  "real minus int"
234
    gdb_test "p 5.0 - 2.0"      " = 3"  "real minus real"
235
 
236
    # Test multiplication with various operands
237
 
238
    gdb_test "p .TRUE. * 1"     " = 1"  "bool times int"
239
    gdb_test "p 2 * 3"          " = 6"  "int times int"
240
    gdb_test "p 2.0 * 3"        " = 6"  "real times int"
241
    gdb_test "p 2.0 * 3.0"      " = 6"  "real times real"
242
 
243
    # Test division with various operands
244
 
245
    gdb_test "p .TRUE. / 1"     " = 1"  "bool divided by int"
246
    gdb_test "p 6 / 3"          " = 2"  "int divided by int"
247
    gdb_test "p 6.0 / 3"        " = 2"  "real divided by int"
248
    gdb_test "p 6.0 / 3.0"      " = 2"  "real divided by real"
249
 
250
    # Test modulo with various operands
251
 
252
}
253
 
254
# Start with a fresh gdb.
255
 
256
gdb_exit
257
gdb_start
258
gdb_reinitialize_dir $srcdir/$subdir
259
 
260
gdb_test "set print sevenbit-strings" ""
261
 
262
if [set_lang_fortran] then {
263
    test_value_history
264
    test_convenience_variables
265
    test_integer_literals_accepted
266
    test_integer_literals_rejected
267
    test_logical_literals_accepted
268
    test_character_literals_accepted
269
    test_float_literals_accepted
270
    test_arithmetic_expressions
271
} else {
272
    warning "$test_name tests suppressed." 0
273
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.