1 # Copyright (C) 2007 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
18 # This file is part of the gdb testsuite. It contains test for evaluating
19 # simple decimal floating point (DFP) expression.
25 proc test_dfp_literals_accepted {} {
27 # Test various dfp values, covering 32-bit, 64-bit and 128-bit ones
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"
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"
41 # The largest exponent for 32-bit dfp value is 96.
42 gdb_test "p 1.2E96df" " = 1.200000E\\+96"
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"
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"
56 # The largest exponent for 64-bit dfp value is 384.
57 gdb_test "p 1.2E384dd" " = 1.200000000000000E\\+384"
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"
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"
71 # The largest exponent for 128-bit dfp value is 6144.
72 gdb_test "p 1.2E6144dl" " = 1.200000000000000000000000000000000E\\+6144"
75 proc test_dfp_arithmetic_expressions {} {
77 # Arithmetic operations for DFP types are not yet implemented in GDB.
78 # These tests are to verify that they will generate expected error messages.
80 gdb_test "p 1.4df + 1.2df" "Argument to arithmetic operation not a number or boolean.*"
81 gdb_test "p 1.4df - 1.2df" ".*Argument to arithmetic operation not a number or boolean.*"
82 gdb_test "p 1.4df * 1.2df" "Argument to arithmetic operation not a number or boolean.*"
83 gdb_test "p 1.4df / 1.2df" "Argument to arithmetic operation not a number or boolean.*"
87 # Start with a fresh gdb.
91 gdb_reinitialize_dir $srcdir/$subdir
93 test_dfp_literals_accepted
94 test_dfp_arithmetic_expressions