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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.chill/] [chexp.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
# Copyright (C) 1992, 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 written by Fred Fish. (fnf@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 chill.  This counts as a test.  If it
30
# fails, then we skip the other tests.
31
 
32
proc set_lang_chill {} {
33
    global gdb_prompt
34
 
35
    send_gdb "set language chill\n"
36
    gdb_expect {
37
        -re ".*$gdb_prompt $" {}
38
        timeout { fail "set language chill (timeout)" ; return 0 }
39
    }
40
 
41
    send_gdb "show language\n"
42
    gdb_expect {
43
        -re ".* source language is \"chill\".*$gdb_prompt $" {
44
            pass "set language to \"chill\""
45
            return 1
46
        }
47
        -re ".*$gdb_prompt $" {
48
            fail "setting language to \"chill\""
49
            return 0
50
        }
51
        timeout {
52
            fail "can't show language (timeout)"
53
            return 0
54
        }
55
    }
56
}
57
 
58
proc test_integer_literals_accepted {} {
59
    global gdb_prompt
60
 
61
    # Test various decimal values.
62
 
63
    gdb_test "p 123" " = 123"
64
    gdb_test "p -123" " = -123"
65
    gdb_test "p D'123" " = 123"
66
    gdb_test "p d'123" " = 123"
67
    gdb_test "p -D'123" " = -123"
68
    gdb_test "p -d'123" " = -123"
69
    gdb_test "p 12_345" " = 12345"
70
    gdb_test "p __1_2_3__" " = 123"
71
    gdb_test "p/d 123" " = D'123"
72
 
73
    # Test various binary values.
74
 
75
    gdb_test "p B'111" " = 7"
76
    gdb_test "p b'111" " = 7"
77
    gdb_test "p -B'111" " = -7"
78
    gdb_test "p B'0111" " = 7"
79
    gdb_test "p b'0111" " = 7"
80
    gdb_test "p -b'0111" " = -7"
81
    gdb_test "p B'_0_1_1_1_" " = 7"
82
    gdb_test "p b'_0_1_1_1_" " = 7"
83
    gdb_test "p -b'_0_1_1_1_" " = -7"
84
    gdb_test "p/t B'111" " = B'111"
85
 
86
    # Test various octal values.
87
 
88
    gdb_test "p O'123" " = 83"
89
    gdb_test "p o'123" " = 83"
90
    gdb_test "p -o'0123" " = -83"
91
    gdb_test "p O'0123" " = 83"
92
    gdb_test "p o'0123" " = 83"
93
    gdb_test "p -o'123" " = -83"
94
    gdb_test "p O'_1_2_3_" " = 83"
95
    gdb_test "p o'_1_2_3_" " = 83"
96
    gdb_test "p -o'_1_2_3_" " = -83"
97
    gdb_test "p/o O'123" " = O'123"
98
 
99
    # Test various hexadecimal values.
100
 
101
    gdb_test "p H'123" " = 291"
102
    gdb_test "p h'123" " = 291"
103
    gdb_test "p -h'123" " = -291"
104
    gdb_test "p H'0123" " = 291"
105
    gdb_test "p h'0123" " = 291"
106
    gdb_test "p -h'0123" " = -291"
107
    gdb_test "p H'_1_2_3_" " = 291"
108
    gdb_test "p h'_1_2_3_" " = 291"
109
    gdb_test "p -h'_1_2_3_" " = -291"
110
    gdb_test "p H'ABC" " = 2748"
111
    gdb_test "p H'abc" " = 2748"
112
    gdb_test "p H'AbC" " = 2748"
113
    gdb_test "p H'_A_b_C_" " = 2748"
114
    gdb_test "p H'_D_e_F_" " = 3567"
115
    gdb_test "p H'_d_E_f_" " = 3567"
116
    gdb_test "p/x H'123" " = H'123"
117
}
118
 
119
proc test_character_literals_accepted {} {
120
    global gdb_prompt
121
 
122
    # Test various decimal values.
123
 
124
    gdb_test "p 'a'" " = 'a'"
125
    gdb_test "p/x 'a'" " = H'61"
126
    gdb_test "p/d 'a'" " = D'97"
127
    gdb_test "p/t 'a'" " = B'1100001"
128
    # gdb_test "p '^(97)'" " = 'a'"     (not in GNU Chill)
129
    gdb_test "p C'61'" " = 'a'"
130
    gdb_test "p c'61'" " = 'a'"
131
    gdb_test "p/x C'FF'" " = H'ff"
132
    # gdb_test "p/x '^(H'FF)'" " = H'ff"        (not in GNU Chill)
133
    # gdb_test "p/x '^(D'255)'" " = H'ff"       (not in GNU Chill)
134
}
135
 
136
proc test_integer_literals_rejected {} {
137
    global gdb_prompt
138
 
139
    # These are valid integer literals in Z.200, but not GNU-Chill.
140
 
141
    test_print_reject "p _"
142
    test_print_reject "p __"
143
 
144
    test_print_reject "p D'"
145
    test_print_reject "p D'_"
146
    test_print_reject "p D'__"
147
 
148
    test_print_reject "p B'"
149
    test_print_reject "p B'_"
150
    test_print_reject "p B'__"
151
 
152
    test_print_reject "p O'"
153
    test_print_reject "p O'_"
154
    test_print_reject "p O'__"
155
 
156
    test_print_reject "p H'"
157
    test_print_reject "p H'_"
158
    test_print_reject "p H'__"
159
 
160
    # Test various decimal values.
161
 
162
    test_print_reject "p D'DEADBEEF"
163
    test_print_reject "p D'123DEADBEEF"
164
 
165
    # Test various binary values.
166
 
167
    test_print_reject "p B'2" "Too-large digit in bitstring or integer."
168
    test_print_reject "p B'12"  "Too-large digit in bitstring or integer."
169
 
170
    # Test various octal values.
171
 
172
    test_print_reject "p O'9"  "Too-large digit in bitstring or integer."
173
    test_print_reject "p O'79"  "Too-large digit in bitstring or integer."
174
 
175
    # Test various hexadecimal values.
176
 
177
    test_print_reject "p H'G" "Invalid character in bitstring or integer."
178
    test_print_reject "p H'AG" "Invalid character in bitstring or integer."
179
}
180
 
181
proc test_boolean_literals_accepted {} {
182
    global gdb_prompt
183
 
184
    # Test the only possible values for a boolean, TRUE and FALSE.
185
 
186
    gdb_test "p TRUE" " = TRUE"
187
    gdb_test "p FALSE" " = FALSE"
188
}
189
 
190
proc test_float_literals_accepted {} {
191
    global gdb_prompt
192
 
193
    # Test various floating point formats
194
 
195
    gdb_test "p .44 < .45" " = TRUE"
196
    gdb_test "p .44 > .45" " = FALSE"
197
    gdb_test "p 0.44 < 0.45" " = TRUE"
198
    gdb_test "p 0.44 > 0.45" " = FALSE"
199
    gdb_test "p 44. < 45." " = TRUE"
200
    gdb_test "p 44. > 45." " = FALSE"
201
    gdb_test "p 44.0 < 45.0" " = TRUE"
202
    gdb_test "p 44.0 > 45.0" " = FALSE"
203
    gdb_test "p 10D20 < 10D21" " = TRUE"
204
    gdb_test "p 10D20 > 10D21" " = FALSE"
205
    gdb_test "p 10d20 < 10d21" " = TRUE"
206
    gdb_test "p 10d20 > 10d21" " = FALSE"
207
    gdb_test "p 10E20 < 10E21" " = TRUE"
208
    gdb_test "p 10E20 > 10E21" " = FALSE"
209
    gdb_test "p 10e20 < 10e21" " = TRUE"
210
    gdb_test "p 10e20 > 10e21" " = FALSE"
211
    gdb_test "p 10.D20 < 10.D21" " = TRUE"
212
    gdb_test "p 10.D20 > 10.D21" " = FALSE"
213
    gdb_test "p 10.d20 < 10.d21" " = TRUE"
214
    gdb_test "p 10.d20 > 10.d21" " = FALSE"
215
    gdb_test "p 10.E20 < 10.E21" " = TRUE"
216
    gdb_test "p 10.E20 > 10.E21" " = FALSE"
217
    gdb_test "p 10.e20 < 10.e21" " = TRUE"
218
    gdb_test "p 10.e20 > 10.e21" " = FALSE"
219
    gdb_test "p 10.0D20 < 10.0D21" " = TRUE"
220
    gdb_test "p 10.0D20 > 10.0D21" " = FALSE"
221
    gdb_test "p 10.0d20 < 10.0d21" " = TRUE"
222
    gdb_test "p 10.0d20 > 10.0d21" " = FALSE"
223
    gdb_test "p 10.0E20 < 10.0E21" " = TRUE"
224
    gdb_test "p 10.0E20 > 10.0E21" " = FALSE"
225
    gdb_test "p 10.0e20 < 10.0e21" " = TRUE"
226
    gdb_test "p 10.0e20 > 10.0e21" " = FALSE"
227
    gdb_test "p 10.0D+20 < 10.0D+21" " = TRUE"
228
    gdb_test "p 10.0D+20 > 10.0D+21" " = FALSE"
229
    gdb_test "p 10.0d+20 < 10.0d+21" " = TRUE"
230
    gdb_test "p 10.0d+20 > 10.0d+21" " = FALSE"
231
    gdb_test "p 10.0E+20 < 10.0E+21" " = TRUE"
232
    gdb_test "p 10.0E+20 > 10.0E+21" " = FALSE"
233
    gdb_test "p 10.0e+20 < 10.0e+21" " = TRUE"
234
    gdb_test "p 10.0e+20 > 10.0e+21" " = FALSE"
235
    gdb_test "p 10.0D-11 < 10.0D-10" " = TRUE"
236
    gdb_test "p 10.0D-11 > 10.0D-10" " = FALSE"
237
    gdb_test "p 10.0d-11 < 10.0d-10" " = TRUE"
238
    gdb_test "p 10.0d-11 > 10.0d-10" " = FALSE"
239
    gdb_test "p 10.0E-11 < 10.0E-10" " = TRUE"
240
    gdb_test "p 10.0E-11 > 10.0E-10" " = FALSE"
241
    gdb_test "p 10.0e-11 < 10.0e-10" " = TRUE"
242
    gdb_test "p 10.0e-11 > 10.0e-10" " = FALSE"
243
    # looks funny, but apparently legal
244
    gdb_test "p _.1e+10 < _.1e+11" " = TRUE"
245
    gdb_test "p _.1e+10 > _.1e+11" " = FALSE"
246
    gdb_test "p __.1e-12 < __.1e-11" " = TRUE"
247
    gdb_test "p __.1e-12 > __.1e-11" " = FALSE"
248
}
249
 
250
proc test_convenience_variables {} {
251
    global gdb_prompt
252
 
253
    gdb_test "set \$foo := 101" " := 101\[\r\]*" \
254
        "Set a new convenience variable"
255
 
256
    gdb_test "print \$foo"              " = 101" \
257
        "Print contents of new convenience variable"
258
 
259
    gdb_test "set \$foo := 301" " := 301\[\r\]*" \
260
        "Set convenience variable to a new value"
261
 
262
    gdb_test "print \$foo"              " = 301" \
263
        "Print new contents of convenience variable"
264
 
265
    gdb_test "set \$_ := 11"            " := 11\[\r\]*" \
266
        "Set convenience variable \$_"
267
 
268
    gdb_test "print \$_"                " = 11" \
269
        "Print contents of convenience variable \$_"
270
 
271
    gdb_test "print \$foo + 10" " = 311" \
272
        "Use convenience variable in arithmetic expression"
273
 
274
    gdb_test "print (\$foo := 32) + 4"  " = 36" \
275
        "Use convenience variable assignment in arithmetic expression"
276
 
277
    gdb_test "print \$bar"              " = void" \
278
        "Print contents of uninitialized convenience variable"
279
}
280
 
281
proc test_value_history {} {
282
    global gdb_prompt
283
 
284
    gdb_test "print 101"        "\\\$1 = 101" \
285
        "Set value-history\[1\] using \$1"
286
 
287
    gdb_test "print 102"        "\\\$2 = 102" \
288
        "Set value-history\[2\] using \$2"
289
 
290
    gdb_test "print 103"        "\\\$3 = 103" \
291
        "Set value-history\[3\] using \$3"
292
 
293
    gdb_test "print \$\$"       "\\\$4 = 102" \
294
        "Print value-history\[MAX-1\] using inplicit index \$\$"
295
 
296
    gdb_test "print \$\$"       "\\\$5 = 103" \
297
        "Print value-history\[MAX-1\] again using implicit index \$\$"
298
 
299
    gdb_test "print \$" "\\\$6 = 103" \
300
        "Print value-history\[MAX\] using implicit index \$"
301
 
302
    gdb_test "print \$\$2"      "\\\$7 = 102" \
303
        "Print value-history\[MAX-2\] using explicit index \$\$2"
304
 
305
    gdb_test "print \$0"        "\\\$8 = 102" \
306
        "Print value-history\[MAX\] using explicit index \$0"
307
 
308
    gdb_test "print 108"        "\\\$9 = 108" ""
309
 
310
    gdb_test "print \$\$0"      "\\\$10 = 108" \
311
        "Print value-history\[MAX\] using explicit index \$\$0"
312
 
313
    gdb_test "print \$1"        "\\\$11 = 101" \
314
        "Print value-history\[1\] using explicit index \$1"
315
 
316
    gdb_test "print \$2"        "\\\$12 = 102" \
317
        "Print value-history\[2\] using explicit index \$2"
318
 
319
    gdb_test "print \$3"        "\\\$13 = 103" \
320
        "Print value-history\[3\] using explicit index \$3"
321
 
322
    gdb_test "print \$-3"       "\\\$14 = 100" \
323
        "Print (value-history\[MAX\] - 3) using implicit index \$"
324
 
325
    gdb_test "print \$1 + 3"    "\\\$15 = 104" \
326
        "Use value-history element in arithmetic expression"
327
}
328
 
329
proc test_arithmetic_expressions {} {
330
    global gdb_prompt
331
 
332
    # Test unary minus with various operands
333
 
334
#    gdb_test "p -(TRUE)"       " = -1" "unary minus applied to bool"
335
#    gdb_test "p -('a')"        " = xxx"        "unary minus applied to char"
336
    gdb_test "p -(1)"           " = -1" "unary minus applied to int"
337
    gdb_test "p -(1.0)" " = -1" "unary minus applied to real"
338
 
339
    # Test addition with various operands
340
 
341
    gdb_test "p TRUE + 1"       " = 2"  "bool plus int"
342
    gdb_test "p 'a' + 1"        " = 98" "char plus int"
343
    gdb_test "p 1 + 1"          " = 2"  "int plus int"
344
    gdb_test "p 1.0 + 1"        " = 2"  "real plus int"
345
    gdb_test "p 1.0 + 2.0"      " = 3"  "real plus real"
346
 
347
    # Test subtraction with various operands
348
 
349
    gdb_test "p TRUE - 1"       " = 0"  "bool minus int"
350
    gdb_test "p 'b' - 1"        " = 97" "char minus int"
351
    gdb_test "p 3 - 1"          " = 2"  "int minus int"
352
    gdb_test "p 3.0 - 1"        " = 2"  "real minus int"
353
    gdb_test "p 5.0 - 2.0"      " = 3"  "real minus real"
354
 
355
    # Test multiplication with various operands
356
 
357
    gdb_test "p TRUE * 1"       " = 1"  "bool times int"
358
    gdb_test "p 'a' * 2"        " = 194"        "char times int"
359
    gdb_test "p 2 * 3"          " = 6"  "int times int"
360
    gdb_test "p 2.0 * 3"        " = 6"  "real times int"
361
    gdb_test "p 2.0 * 3.0"      " = 6"  "real times real"
362
 
363
    # Test division with various operands
364
 
365
    gdb_test "p TRUE / 1"       " = 1"  "bool divided by int"
366
    gdb_test "p 'a' / 2"        " = 48" "char divided by int"
367
    gdb_test "p 6 / 3"          " = 2"  "int divided by int"
368
    gdb_test "p 6.0 / 3"        " = 2"  "real divided by int"
369
    gdb_test "p 6.0 / 3.0"      " = 2"  "real divided by real"
370
 
371
    # Test modulo with various operands
372
 
373
    gdb_test "p TRUE MOD 1"     " = 0"  "bool modulo int"
374
    gdb_test "p 'a' MOD 2"      " = 1"  "char modulo int"
375
    gdb_test "p -5 MOD 3"       " = 1"  "negative int modulo int"
376
    gdb_test "p 5 MOD 1"        " = 0"  "int modulo int"
377
    gdb_test "p 5 MOD 2"        " = 1"  "int modulo int"
378
    gdb_test "p 5 MOD 3"        " = 2"  "int modulo int"
379
    gdb_test "p 5 MOD 4"        " = 1"  "int modulo int"
380
    gdb_test "p 5 MOD 5"        " = 0"  "int modulo int"
381
    gdb_test "p 0 MOD 1"        " = 0"  "int modulo int"
382
    gdb_test "p 0 MOD 2"        " = 0"  "int modulo int"
383
    gdb_test "p 0 MOD 3"        " = 0"  "int modulo int"
384
    gdb_test "p 0 MOD 4"        " = 0"  "int modulo int"
385
    gdb_test "p -5 MOD 1"       " = 0"  "int modulo int"
386
    gdb_test "p -5 MOD 2"       " = 1"  "int modulo int"
387
    gdb_test "p -5 MOD 3"       " = 1"  "int modulo int"
388
    gdb_test "p -5 MOD 4"       " = 3"  "int modulo int"
389
    gdb_test "p -5 MOD 5"       " = 0"  "int modulo int"
390
    gdb_test "p -5 MOD 5"       " = 0"  "int modulo int"
391
    test_print_reject "p 6.0 MOD 3" \
392
        "Integer-only operation on floating point number.*"
393
    test_print_reject "p 6.0 MOD 3.0" \
394
        "Integer-only operation on floating point number.*"
395
    test_print_reject "p -5 MOD -1" \
396
        "Second operand of MOD must be greater than zero.*"
397
    test_print_reject "p -5 MOD 0" \
398
        "Second operand of MOD must be greater than zero.*"
399
 
400
    # Test remainder with various operands
401
 
402
    gdb_test "p TRUE REM 1"     " = 0"  "bool remainder int"
403
    gdb_test "p 'a' REM 2"      " = 1"  "char remainder int"
404
    gdb_test "p 5 REM 5"        " = 0"  "int remainder int"
405
    gdb_test "p 5 REM 4"        " = 1"  "int remainder int"
406
    gdb_test "p 5 REM 3"        " = 2"  "int remainder int"
407
    gdb_test "p 5 REM 2"        " = 1"  "int remainder int"
408
    gdb_test "p 5 REM 1"        " = 0"  "int remainder int"
409
    gdb_test "p 5 REM -1"       " = 0"  "int remainder int"
410
    gdb_test "p 5 REM -2"       " = 1"  "int remainder int"
411
    gdb_test "p 5 REM -3"       " = 2"  "int remainder int"
412
    gdb_test "p 5 REM -4"       " = 1"  "int remainder int"
413
    gdb_test "p 5 REM -5"       " = 0"  "int remainder int"
414
    gdb_test "p -5 REM 5"       " = 0"  "int remainder int"
415
    gdb_test "p -5 REM 4"       " = -1" "int remainder int"
416
    gdb_test "p -5 REM 3"       " = -2" "int remainder int"
417
    gdb_test "p -5 REM 2"       " = -1" "int remainder int"
418
    gdb_test "p -5 REM 1"       " = 0"  "int remainder int"
419
    gdb_test "p -5 REM -1"      " = 0"  "int remainder int"
420
    gdb_test "p -5 REM -2"      " = -1" "int remainder int"
421
    gdb_test "p -5 REM -3"      " = -2" "int remainder int"
422
    gdb_test "p -5 REM -4"      " = -1" "int remainder int"
423
    gdb_test "p -5 REM -5"      " = 0"  "int remainder int"
424
    gdb_test "p 6 REM 3"        " = 0"  "int remainder int"
425
    test_print_reject "p 6.0 REM 3" \
426
        "Integer-only operation on floating point number.*"
427
    test_print_reject "p 6.0 REM 3.0" \
428
        "Integer-only operation on floating point number.*"
429
}
430
 
431
# Start with a fresh gdb.
432
 
433
gdb_exit
434
gdb_start
435
gdb_reinitialize_dir $srcdir/$subdir
436
 
437
gdb_test "set print sevenbit-strings" ""
438
 
439
if [set_lang_chill] then {
440
    test_value_history
441
    test_convenience_variables
442
    test_integer_literals_accepted
443
    test_integer_literals_rejected
444
    test_boolean_literals_accepted
445
    test_character_literals_accepted
446
    test_float_literals_accepted
447
    test_arithmetic_expressions
448
} else {
449
    warning "$test_name tests suppressed." 0
450
}

powered by: WebSVN 2.1.0

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