This is related to #103, but a bit more cases. Considering the following test program, running with perl 5.28.1, Mouse v2.5.9. The test program take each strings from @ARGV as $x, and "wash" it with "int($x)" -- which leaves some side-effect inside $x. Then see if it passes Int type constraint.
# x.pl
use v5.18;
use warnings;
use Mouse::Util::TypeConstraints;
my $Int = find_type_constraint 'Int';
for my $x (@ARGV) {
{ no warnings; int($x); };
if ($Int->check($x)) {
say " Int\t$x";
} else {
say "!Int\t$x";
}
}
Here's the output when using Mouse::XS
> perl x.pl 1 '-1' '-0' ' 1 ' ' -1 ' 0 00 010 18446744073709551615 1.0 0.1 1.2.3 0.0 0.1.0 0b00 0e 0e0 0e1 1e0 '0 but true' '1 foobar'
Int 1
Int -1
Int -0
Int 1
Int -1
Int 0
Int 00
Int 010
Int 18446744073709551615
!Int 1.0
!Int 0.1
!Int 1.2.3
!Int 0.0
!Int 0.1.0
!Int 0b00
!Int 0e
!Int 0e0
!Int 0e1
!Int 1e0
Int 0 but true
!Int 1 foobar
The output when using Mouse::PurePerl
> MOUSE_PUREPERL=1 perl x.pl 1 '-1' '-0' ' 1 ' ' -1 ' 0 00 010 18446744073709551615 1.0 0.1 1.2.3 0.0 0.1.0 0b00 0e 0e0 0e1 1e0 '0 but true' '1 foobar'
Int 1
Int -1
Int -0
!Int 1
!Int -1
Int 0
Int 00
Int 010
Int 18446744073709551615
!Int 1.0
!Int 0.1
!Int 1.2.3
!Int 0.0
!Int 0.1.0
!Int 0b00
!Int 0e
!Int 0e0
!Int 0e1
!Int 1e0
!Int 0 but true
!Int 1 foobar
Trivial values are consistent, values with leading/trailing spaces and a special value "0 but true" are controversial.
IMHO, the result from Mouse::PurePerl looks intuitively correct and we should change Mouse::XS to match that result -- but I also pondering the counter-argument here.
This is related to #103, but a bit more cases. Considering the following test program, running with perl 5.28.1, Mouse v2.5.9. The test program take each strings from
@ARGV
as$x
, and "wash" it with"int($x)"
-- which leaves some side-effect inside$x
. Then see if it passes Int type constraint.Here's the output when using Mouse::XS
The output when using Mouse::PurePerl
Trivial values are consistent, values with leading/trailing spaces and a special value "0 but true" are controversial.
IMHO, the result from
Mouse::PurePerl
looks intuitively correct and we should changeMouse::XS
to match that result -- but I also pondering the counter-argument here.