Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Int check on large unsigned integers #9

Merged
merged 1 commit into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';