Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dfp-exprs.exp
CommitLineData
9b254dd1 1# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
93004d61
TJB
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 <http://www.gnu.org/licenses/>.
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
21if $tracelevel then {
22 strace $tracelevel
23}
24
25proc 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
75proc test_dfp_arithmetic_expressions {} {
76
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.
79
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.*"
84
85}
86
87# Start with a fresh gdb.
88
89gdb_exit
90gdb_start
91gdb_reinitialize_dir $srcdir/$subdir
92
93test_dfp_literals_accepted
94test_dfp_arithmetic_expressions
This page took 0.066913 seconds and 4 git commands to generate.