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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.fortran/] [exprs.exp] - Blame information for rev 330

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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