Skip to content

Commit

Permalink
LL fix for broken set_c (in fact broken typemap)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmx committed Sep 4, 2015
1 parent e7636f5 commit a441f34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Basic/Core/typemap
Expand Up @@ -18,13 +18,13 @@ T_PDL_ANYVAL
$var.type = -1;
$var.value.B = 0;
} else if (SvIOK($arg)) {
#if IVSIZE == 8
\#if IVSIZE == 8
$var.type = PDL_LL;
$var.value.Q = (PDL_LongLong) SvIV($arg);
#else
\#else
$var.type = PDL_L;
$var.value.L = (PDL_Long) SvIV($arg);
#endif
\#endif
} else {
$var.type = PDL_D;
$var.value.D = (PDL_Double) SvNV($arg);
Expand Down
7 changes: 3 additions & 4 deletions Basic/Core/typemap.pdl
Expand Up @@ -18,13 +18,13 @@ T_PDL_ANYVAL
$var.type = -1;
$var.value.B = 0;
} else if (SvIOK($arg)) {
#if IVSIZE == 8
\#if IVSIZE == 8
$var.type = PDL_LL;
$var.value.Q = (PDL_LongLong) SvIV($arg);
#else
\#else
$var.type = PDL_L;
$var.value.L = (PDL_Long) SvIV($arg);
#endif
\#endif
} else {
$var.type = PDL_D;
$var.value.D = (PDL_Double) SvNV($arg);
Expand All @@ -36,7 +36,6 @@ T_PDLTRANS
else
croak(\"$var is not of type PDL::Trans\");


OUTPUT

T_PDL
Expand Down
11 changes: 10 additions & 1 deletion t/unpdl.t
Expand Up @@ -3,7 +3,7 @@ use warnings;

use PDL;
use Config;
use Test::More tests => 2;
use Test::More tests => 7;

my $array = [
[[1,2],
Expand Down Expand Up @@ -47,5 +47,14 @@ SKIP:
8999999999999999996,
9223372036854775807, #max int64
];

is_deeply(longlong($input)->unpdl, $input, 'back convert of 64bit integers');
my $small_pdl = longlong([ -9000000000000000001, 9000000000000000001 ]);
is($small_pdl->at(0), -9000000000000000001, 'at/1');
is(PDL::Core::at_c($small_pdl, [1]), 9000000000000000001, 'at_c/1');
$small_pdl->set(0, -8888888888888888888);
PDL::Core::set_c($small_pdl, [1], 8888888888888888888);
is($small_pdl->at(0), -8888888888888888888, 'at/2');
is(PDL::Core::at_c($small_pdl, [1]), 8888888888888888888, 'at_c/2');
is_deeply($small_pdl->unpdl, [ -8888888888888888888, 8888888888888888888 ], 'unpdl/small_pdl');
}

0 comments on commit a441f34

Please sign in to comment.