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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [dfp-exprs.exp] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright (C) 2007, 2008, 2009, 2010 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 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 .
15
 
16
# This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
17
 
18
# This file is part of the gdb testsuite.  It contains test for evaluating
19
# simple decimal floating point (DFP) expression.
20
 
21
if $tracelevel then {
22
        strace $tracelevel
23
}
24
 
25
proc test_dfp_literals_accepted {} {
26
 
27
    # Test various dfp values, covering 32-bit, 64-bit and 128-bit ones
28
 
29
    # _Decimal32 constants, which can support up to 7 digits
30
    gdb_test "p 1.2df" " = 1.2"
31
    gdb_test "p -1.2df" " = -1.2"
32
    gdb_test "p 1.234567df" " = 1.234567"
33
    gdb_test "p -1.234567df" " = -1.234567"
34
    gdb_test "p 1234567.df" " = 1234567"
35
    gdb_test "p -1234567.df" " = -1234567"
36
 
37
    gdb_test "p 1.2E1df" " = 12"
38
    gdb_test "p 1.2E10df" " = 1.2E\\+10"
39
    gdb_test "p 1.2E-10df" " = 1.2E-10"
40
 
41
    # The largest exponent for 32-bit dfp value is 96.
42
    gdb_test "p 1.2E96df" " = 1.200000E\\+96"
43
 
44
    # _Decimal64 constants, which can support up to 16 digits
45
    gdb_test "p 1.2dd" " = 1.2"
46
    gdb_test "p -1.2dd" " = -1.2"
47
    gdb_test "p 1.234567890123456dd" " = 1.234567890123456"
48
    gdb_test "p -1.234567890123456dd" " = -1.234567890123456"
49
    gdb_test "p 1234567890123456.dd" " = 1234567890123456"
50
    gdb_test "p -1234567890123456.dd" " = -1234567890123456"
51
 
52
    gdb_test "p 1.2E1dd" " = 12"
53
    gdb_test "p 1.2E10dd" " = 1.2E\\+10"
54
    gdb_test "p 1.2E-10dd" " = 1.2E-10"
55
 
56
    # The largest exponent for 64-bit dfp value is 384.
57
    gdb_test "p 1.2E384dd" " = 1.200000000000000E\\+384"
58
 
59
    # _Decimal128 constants, which can support up to 34 digits
60
    gdb_test "p 1.2dl" " = 1.2"
61
    gdb_test "p -1.2dl" " = -1.2"
62
    gdb_test "p 1.234567890123456789012345678901234dl" " = 1.234567890123456789012345678901234"
63
    gdb_test "p -1.234567890123456789012345678901234dl" " = -1.234567890123456789012345678901234"
64
    gdb_test "p 1234567890123456789012345678901234.dl" " = 1234567890123456789012345678901234"
65
    gdb_test "p -1234567890123456789012345678901234.dl" " = -1234567890123456789012345678901234"
66
 
67
    gdb_test "p 1.2E1dl" " = 12"
68
    gdb_test "p 1.2E10dl" " = 1.2E\\+10"
69
    gdb_test "p 1.2E-10dl" " = 1.2E-10"
70
 
71
    # The largest exponent for 128-bit dfp value is 6144.
72
    gdb_test "p 1.2E6144dl" " = 1.200000000000000000000000000000000E\\+6144"
73
}
74
 
75
proc test_dfp_arithmetic_expressions {} {
76
 
77
    # _Decimal32 operands.
78
    gdb_test "p 1.4df + 1.2df" " = 2.6"
79
    gdb_test "p 1.4df - 1.2df" " = 0.2"
80
    gdb_test "p 1.4df * 1.2df" " = 1.68"
81
    gdb_test "p 1.4df / 1.2df" " = 1.166667"
82
 
83
    # _Decimal64 operands.
84
    gdb_test "p 1.4dd + 1.2dd" " = 2.6"
85
    gdb_test "p 1.4dd - 1.2dd" " = 0.2"
86
    gdb_test "p 1.4dd * 1.2dd" " = 1.68"
87
    gdb_test "p 1.4dd / 1.2dd" " = 1.166666666666667"
88
 
89
    # _Decimal128 operands.
90
    gdb_test "p 1.4dl + 1.2dl" " = 2.6"
91
    gdb_test "p 1.4dl - 1.2dl" " = 0.2"
92
    gdb_test "p 1.4dl * 1.2dl" " = 1.68"
93
    gdb_test "p 1.4dl / 1.2dl" " = 1.166666666666666666666666666666667"
94
 
95
    # Test type of operation result.
96
    gdb_test "ptype 2.df + 2.df" "= _Decimal32"
97
    gdb_test "ptype 2.dd + 2.dd" "= _Decimal64"
98
    gdb_test "ptype 2.dl + 2.dl" "= _Decimal128"
99
 
100
    # Mixture of different _Decimal sizes.
101
    gdb_test "p 2.1df + 2.7dd" "= 4.8"
102
    gdb_test "p 2.1dd + 2.7df" "= 4.8"
103
    gdb_test "p 2.6df + 2.7dl" "= 5.3"
104
    gdb_test "p 2.6dl + 2.7df" "= 5.3"
105
    gdb_test "p 2.3dd + 2.2dl" "= 4.5"
106
    gdb_test "p 2.3dl + 2.2dd" "= 4.5"
107
    gdb_test "ptype 2.df + 2.dd" "= _Decimal64"
108
    gdb_test "ptype 2.df + 2.dl" "= _Decimal128"
109
    gdb_test "ptype 2.dd + 2.dl" "= _Decimal128"
110
 
111
    # Mixture of Decimal and integral operands
112
    gdb_test "p 1.2df + 1" " = 2.2"
113
    gdb_test "p 2 + 1.7dd" " = 3.7"
114
    gdb_test "p 3 + 2.1dl" " = 5.1"
115
    gdb_test "ptype 1.2df + 1" " = _Decimal32"
116
    gdb_test "ptype 2 + 1.7dd" " = _Decimal64"
117
    gdb_test "ptype 3 + 2.1dl" " = _Decimal128"
118
 
119
    # Reject operation with integral larger than 32-bits
120
    gdb_test "p 1.2df + 2ll" "Conversion of large integer to a decimal floating type is not supported."
121
 
122
    # Reject operation with DFP and Binary FP
123
    gdb_test "p 1.2df + 1.2f" "Mixing decimal floating types with other floating types is not allowed."
124
 
125
    # Test other operations with DFP operands
126
    gdb_test "p !0.df" " = 1"
127
    gdb_test "p !0.dd" " = 1"
128
    gdb_test "p !0.dl" " = 1"
129
    gdb_test "p !0.5df" " = 0"
130
    gdb_test "p !0.5dd" " = 0"
131
    gdb_test "p !0.5dl" " = 0"
132
 
133
    gdb_test "p 1.2df == 1.2df" " = 1"
134
    gdb_test "p 1.2df == 1.2dd" " = 1"
135
    gdb_test "p 1.2df == 1.2dl" " = 1"
136
    gdb_test "p 1.2dd == 1.2df" " = 1"
137
    gdb_test "p 1.2dd == 1.2dl" " = 1"
138
    gdb_test "p 1.2dl == 1.2df" " = 1"
139
    gdb_test "p 1.2dl == 1.2dd" " = 1"
140
    gdb_test "p 1.2df == 1.3df" " = 0"
141
    gdb_test "p 1.2df == 1.3dd" " = 0"
142
    gdb_test "p 1.2df == 1.3dl" " = 0"
143
    gdb_test "p 1.2dd == 1.3df" " = 0"
144
    gdb_test "p 1.2dd == 1.3dl" " = 0"
145
    gdb_test "p 1.2dl == 1.3df" " = 0"
146
    gdb_test "p 1.2dl == 1.3dd" " = 0"
147
 
148
    gdb_test "p +1.2df" " = 1.2"
149
    gdb_test "p +1.2dd" " = 1.2"
150
    gdb_test "p +1.2dl" " = 1.2"
151
 
152
    gdb_test "p 1.2df < 1.3df" " = 1"
153
    gdb_test "p 1.2df < 1.3dd" " = 1"
154
    gdb_test "p 1.2dl < 1.3df" " = 1"
155
    gdb_test "p 1.2dd < 1.3dd" " = 1"
156
    gdb_test "p 1.2dd < 1.3dl" " = 1"
157
    gdb_test "p 1.2dl < 1.3dl" " = 1"
158
    gdb_test "p 1.2dl < 1.3df" " = 1"
159
    gdb_test "p 1.2df > 1" " = 1"
160
    gdb_test "p 1.2dl > 2" " = 0"
161
    gdb_test "p 2 > 1.2dd" " = 1"
162
    gdb_test "p 2 > 3.1dl" " = 0"
163
}
164
 
165
proc test_dfp_conversions {} {
166
    # Test cast to and from DFP values, and between DFPs of different sizes
167
 
168
    gdb_test "p (float) -0.1df" " = -0.(0999.*|1000.*)"
169
    gdb_test "p (int) 8.3dd" " = 8"
170
    gdb_test "p (_Decimal64) 3.1" " = 3.(0999.*|1000.*)"
171
    gdb_test "p (_Decimal128) 3.7df" " = 3.7"
172
    gdb_test "p (_Decimal32) 4" " = 4"
173
}
174
 
175
# Start with a fresh gdb.
176
 
177
gdb_exit
178
gdb_start
179
gdb_reinitialize_dir $srcdir/$subdir
180
 
181
test_dfp_literals_accepted
182
test_dfp_arithmetic_expressions
183
test_dfp_conversions

powered by: WebSVN 2.1.0

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