Skip to content

Commit

Permalink
Merge pull request #9 from haarg/maxuint
Browse files Browse the repository at this point in the history
fix Int check on large unsigned integers
  • Loading branch information
tobyink authored Sep 5, 2019
2 parents 514e374 + 07beaf9 commit e71617b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions XS.xs
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ int
typetiny_tc_Int(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
assert(sv);
if (SvOK(sv) && !SvROK(sv) && !isGV(sv)) {
if(SvPOKp(sv)){
if(SvPOK(sv)){
return S_pv_is_integer(aTHX_ SvPVX(sv));
}
else if(SvNOKp(sv)) {
return S_nv_is_integer(aTHX_ SvNVX(sv));
}
else if(SvIOKp(sv)){
else if(SvIOK(sv)){
return TRUE;
}
else if(SvNOK(sv)) {
return S_nv_is_integer(aTHX_ SvNVX(sv));
}
}
return FALSE;
}
Expand Down
6 changes: 5 additions & 1 deletion t/02int.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ the same terms as the Perl 5 programming language system itself.

use strict;
use warnings;
use Test::More tests => 17;
use Test::More tests => 19;

use_ok('Type::Tiny::XS');

Expand All @@ -42,3 +42,7 @@ ok !Type::Tiny::XS::Int("123\n") => 'no "123\\n"';
ok !Type::Tiny::XS::Int("\n123") => 'no "\\n123"';
ok !Type::Tiny::XS::Int("2.3") => 'no "2.3"';
ok !Type::Tiny::XS::Int( 2.3 ) => 'no 2.3';
my $maxuint = ~0;
ok Type::Tiny::XS::Int( $maxuint ) => 'yes MAXUINT';
my $as_string = sprintf '%f', $maxuint;
ok Type::Tiny::XS::Int( $maxuint ) => 'yes MAXUINT after use as float';

0 comments on commit e71617b

Please sign in to comment.