]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/complex-parts.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / complex-parts.exp
CommitLineData
1d506c26 1# Copyright 2019-2024 Free Software Foundation, Inc.
8bdc1658
AB
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
16standard_testfile
17
18if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
19 return -1
20}
21
65a33d75 22if {![runto_main]} {
8bdc1658
AB
23 return 0
24}
25
26gdb_breakpoint [gdb_get_line_number "Break Here"]
27gdb_continue_to_breakpoint "breakpt" ".* Break Here\\. .*"
28
981c08ce
TT
29gdb_test "p z1" " = 1.5 \\+ 4.5i"
30gdb_test "p z2" " = 2.5 \\+ -5.5i"
31gdb_test "p z3" " = 3.5 \\+ 6.5i"
8bdc1658 32
fbdc50d2
BL
33# The following 3 tests are broken for Clang.
34# More info at https://github.com/llvm/llvm-project/issues/52996.
35if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
8bdc1658 36gdb_test "ptype z1" " = complex double"
fbdc50d2 37if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
8bdc1658 38gdb_test "ptype z2" " = complex float"
fbdc50d2 39if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
8bdc1658
AB
40gdb_test "ptype z3" " = complex long double"
41
c2b75043
LM
42with_test_prefix "double imaginary" {
43 gdb_test "p \$_cimag (z1)" " = 4.5"
44 gdb_test "ptype \$" " = double"
45}
8bdc1658 46
c2b75043
LM
47with_test_prefix "float imaginary" {
48 gdb_test "p \$_cimag (z2)" " = -5.5"
49 gdb_test "ptype \$" " = float"
50}
8bdc1658 51
c2b75043
LM
52with_test_prefix "long double imaginary" {
53 gdb_test "p \$_cimag (z3)" " = 6.5"
54 gdb_test "ptype \$" " = long double"
55}
8bdc1658 56
c2b75043
LM
57with_test_prefix "double real" {
58 gdb_test "p \$_creal (z1)" " = 1.5"
59 gdb_test "ptype \$" " = double"
60}
8bdc1658 61
c2b75043
LM
62with_test_prefix "float real" {
63 gdb_test "p \$_creal (z2)" " = 2.5"
64 gdb_test "ptype \$" " = float"
65}
8bdc1658 66
c2b75043
LM
67with_test_prefix "long double real" {
68 gdb_test "p \$_creal (z3)" " = 3.5"
69 gdb_test "ptype \$" " = long double"
70}
8bdc1658
AB
71
72gdb_test "p \$_cimag (d1)" "expected a complex number"
73gdb_test "p \$_cimag (f1)" "expected a complex number"
74gdb_test "p \$_cimag (i1)" "expected a complex number"
75
76gdb_test "p \$_creal (d1)" "expected a complex number"
77gdb_test "p \$_creal (f1)" "expected a complex number"
78gdb_test "p \$_creal (i1)" "expected a complex number"
c34e8714
TT
79
80#
81# General complex number tests.
82#
83
84gdb_test "print 23 + 7i" " = 23 \\+ 7i"
85gdb_test "print 23.125f + 7i" " = 23.125 \\+ 7i"
86gdb_test "print 23 + 7.25fi" " = 23 \\+ 7.25i"
87gdb_test "print (23 + 7i) + (17 + 10i)" " = 40 \\+ 17i"
88gdb_test "print 23 + -7i" " = 23 \\+ -7i"
89gdb_test "print 23 - 7i" " = 23 \\+ -7i"
90
91gdb_test "print -(23 + 7i)" " = -23 \\+ -7i"
92gdb_test "print +(23 + 7i)" " = 23 \\+ 7i"
93gdb_test "print ~(23 + 7i)" " = 23 \\+ -7i"
94
95gdb_test "print (5 + 5i) * (2 + 2i)" " = 0 \\+ 20i"
96
97gdb_test "print (5 + 7i) == (5 + 7i)" " = 1"
98gdb_test "print (5 + 7i) == (8 + 7i)" " = 0"
99gdb_test "print (5 + 7i) == (5 + 92i)" " = 0"
100gdb_test "print (5 + 7i) != (5 + 7i)" " = 0"
101gdb_test "print (5 + 7i) != (8 + 7i)" " = 1"
102gdb_test "print (5 + 7i) != (5 + 92i)" " = 1"
103
104gdb_test "print (20 - 4i) / (3 + 2i)" " = 4 \\+ -4i"
3638a098
TT
105
106gdb_test "print (_Complex int) 4" " = 4 \\+ 0i"
107gdb_test "print (_Complex float) 4.5" " = 4.5 \\+ 0i"
108gdb_test "ptype __complex__ short" " = _Complex short"
109gdb_test "print (_Complex int) (23.75 + 8.88i)" " = 23 \\+ 8i"
ae710496
TV
110
111set re_reject_arg "Argument to complex arithmetic operation not supported\\."
112gdb_test "print (void *)0 + 5i" $re_reject_arg
113gdb_test "print (_Decimal32)0 + 5i" $re_reject_arg
114
115# Set language to c++. Avoid warning by not having current frame.
116clean_restart
117gdb_test_no_output "set language c++"
118
119# C++ type tests.
120gdb_test "print (bool)1 + 1i" " = 1 \\+ 1i"