Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2019-2020 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 | ||
16 | standard_testfile | |
17 | ||
18 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | |
19 | return -1 | |
20 | } | |
21 | ||
22 | if { ![runto_main] } then { | |
23 | fail "can't run to main" | |
24 | return 0 | |
25 | } | |
26 | ||
27 | gdb_breakpoint [gdb_get_line_number "Break Here"] | |
28 | gdb_continue_to_breakpoint "breakpt" ".* Break Here\\. .*" | |
29 | ||
981c08ce TT |
30 | gdb_test "p z1" " = 1.5 \\+ 4.5i" |
31 | gdb_test "p z2" " = 2.5 \\+ -5.5i" | |
32 | gdb_test "p z3" " = 3.5 \\+ 6.5i" | |
8bdc1658 AB |
33 | |
34 | gdb_test "ptype z1" " = complex double" | |
35 | gdb_test "ptype z2" " = complex float" | |
36 | gdb_test "ptype z3" " = complex long double" | |
37 | ||
c2b75043 LM |
38 | with_test_prefix "double imaginary" { |
39 | gdb_test "p \$_cimag (z1)" " = 4.5" | |
40 | gdb_test "ptype \$" " = double" | |
41 | } | |
8bdc1658 | 42 | |
c2b75043 LM |
43 | with_test_prefix "float imaginary" { |
44 | gdb_test "p \$_cimag (z2)" " = -5.5" | |
45 | gdb_test "ptype \$" " = float" | |
46 | } | |
8bdc1658 | 47 | |
c2b75043 LM |
48 | with_test_prefix "long double imaginary" { |
49 | gdb_test "p \$_cimag (z3)" " = 6.5" | |
50 | gdb_test "ptype \$" " = long double" | |
51 | } | |
8bdc1658 | 52 | |
c2b75043 LM |
53 | with_test_prefix "double real" { |
54 | gdb_test "p \$_creal (z1)" " = 1.5" | |
55 | gdb_test "ptype \$" " = double" | |
56 | } | |
8bdc1658 | 57 | |
c2b75043 LM |
58 | with_test_prefix "float real" { |
59 | gdb_test "p \$_creal (z2)" " = 2.5" | |
60 | gdb_test "ptype \$" " = float" | |
61 | } | |
8bdc1658 | 62 | |
c2b75043 LM |
63 | with_test_prefix "long double real" { |
64 | gdb_test "p \$_creal (z3)" " = 3.5" | |
65 | gdb_test "ptype \$" " = long double" | |
66 | } | |
8bdc1658 AB |
67 | |
68 | gdb_test "p \$_cimag (d1)" "expected a complex number" | |
69 | gdb_test "p \$_cimag (f1)" "expected a complex number" | |
70 | gdb_test "p \$_cimag (i1)" "expected a complex number" | |
71 | ||
72 | gdb_test "p \$_creal (d1)" "expected a complex number" | |
73 | gdb_test "p \$_creal (f1)" "expected a complex number" | |
74 | gdb_test "p \$_creal (i1)" "expected a complex number" | |
c34e8714 TT |
75 | |
76 | # | |
77 | # General complex number tests. | |
78 | # | |
79 | ||
80 | gdb_test "print 23 + 7i" " = 23 \\+ 7i" | |
81 | gdb_test "print 23.125f + 7i" " = 23.125 \\+ 7i" | |
82 | gdb_test "print 23 + 7.25fi" " = 23 \\+ 7.25i" | |
83 | gdb_test "print (23 + 7i) + (17 + 10i)" " = 40 \\+ 17i" | |
84 | gdb_test "print 23 + -7i" " = 23 \\+ -7i" | |
85 | gdb_test "print 23 - 7i" " = 23 \\+ -7i" | |
86 | ||
87 | gdb_test "print -(23 + 7i)" " = -23 \\+ -7i" | |
88 | gdb_test "print +(23 + 7i)" " = 23 \\+ 7i" | |
89 | gdb_test "print ~(23 + 7i)" " = 23 \\+ -7i" | |
90 | ||
91 | gdb_test "print (5 + 5i) * (2 + 2i)" " = 0 \\+ 20i" | |
92 | ||
93 | gdb_test "print (5 + 7i) == (5 + 7i)" " = 1" | |
94 | gdb_test "print (5 + 7i) == (8 + 7i)" " = 0" | |
95 | gdb_test "print (5 + 7i) == (5 + 92i)" " = 0" | |
96 | gdb_test "print (5 + 7i) != (5 + 7i)" " = 0" | |
97 | gdb_test "print (5 + 7i) != (8 + 7i)" " = 1" | |
98 | gdb_test "print (5 + 7i) != (5 + 92i)" " = 1" | |
99 | ||
100 | gdb_test "print (20 - 4i) / (3 + 2i)" " = 4 \\+ -4i" | |
3638a098 TT |
101 | |
102 | gdb_test "print (_Complex int) 4" " = 4 \\+ 0i" | |
103 | gdb_test "print (_Complex float) 4.5" " = 4.5 \\+ 0i" | |
104 | gdb_test "ptype __complex__ short" " = _Complex short" | |
105 | gdb_test "print (_Complex int) (23.75 + 8.88i)" " = 23 \\+ 8i" |