1use warnings;
2use strict;
3use Math::MPFR qw(:mpfr);
4use Math::MPC qw(:mpc);
5
6eval {require Math::Complex_C::L;};
7
8if($@) {
9  print "1..1\n";
10  warn "Skipping all tests - couldn't load Math::Complex_C::L\n\$\@: $@\n";
11  print "ok 1\n";
12  exit 0;
13}
14
15
16my $count = 3;
17
18print "1..$count\n";
19
20Rmpc_set_default_prec2(200, 200);
21
22unless(Math::MPC::_have_Complex_h()) {
23  warn "Skipping all tests - Math::MPC not built with support for 'double _Complex' & 'long double _Complex' types";
24  for(1 .. $count) {print "ok $_\n"}
25  exit 0;
26}
27
28my $ccl = Math::Complex_C::L->new(4.5, -231.125);
29my $mpcc = Math::MPC->new();
30my $mpfr = Math::MPFR->new();
31
32Rmpc_set_LDC($mpcc, $ccl, MPC_RNDNN);
33
34RMPC_RE($mpfr, $mpcc);
35if($mpfr == 4.5) {print "ok 1\n"}
36else {
37  warn "\$mpfr: $mpfr\n";
38  print "not ok 1\n";
39}
40
41RMPC_IM($mpfr, $mpcc);
42if($mpfr == -231.125) {print "ok 2\n"}
43else {
44  warn "\$mpfr: $mpfr\n";
45  print "not ok 2\n";
46}
47
48Math::Complex_C::L::assign_cl($ccl, 3.19, -12.621);
49
50my $mpccl = Math::MPC->new();
51
52Rmpc_set_LDC($mpccl, $ccl, MPC_RNDNN);
53
54my $ccl_check = Math::Complex_C::L->new();
55
56Rmpc_get_LDC($ccl_check, $mpccl, MPC_RNDNN);
57
58if($ccl_check == $ccl) {print "ok 3\n"}
59else {
60  warn "\$ccl_check: $ccl_check\n\$ccl: $ccl\n";
61  print "not ok 3\n";
62}
63
64