Skip Menu |

This queue is for tickets about the MooX-Types-MooseLike CPAN distribution.

Report information
The Basics
Id: 78074
Status: resolved
Priority: 0/
Queue: MooX-Types-MooseLike

People
Owner: Nobody in particular
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.05
Fixed in: (no value)



Subject: subtypes do not recurse; and SingleDigit is broken
The subtype tests do not recurse. It only runs through the first two levels. This is because the creation itself isn't really recursive. Also, SingleDigit doesn't make sense to be a subtype of 'NegativeIntOrZero'. However, since it's about the only example of a "two-level deep" subtype nesting in your module, I'm going to use it in this code example: package Dummy::MooseLike::Test; use v5.10; use Moo; use MooX::Types::MooseLike::Numeric qw(:all); no strict 'refs'; has 'Test_SingleDigit' => ( is => 'rw', isa => SingleDigit, ); package main; my $obj = Dummy::MooseLike::Test->new(); $obj->Test_SingleDigit(-2.5); ==================== So, it passes SingleDigit, and then passes NegativeIntOrZero, but it doesn't pass Int. However, Int is never checked, and so the value is "valid" without any errors.
https://metacpan.org/source/MATEU/MooX-Types-MooseLike-0.05/lib/MooX/Types/MooseLike.pm Oooo, this is a simple fix: is_type => sub { $full_test->($_[0]) }, Instead of just $test. Also, *.t updates. I have an extensive test plan that found this, if you're interested: https://github.com/SineSwiper/MooX-Types-CLike/blob/master/t/types.t
On Wed Jun 27 16:56:01 2012, BBYRD wrote: Show quoted text
> The subtype tests do not recurse. It only runs through the first two > levels. This is because the creation itself isn't really recursive. > > Also, SingleDigit doesn't make sense to be a subtype of > 'NegativeIntOrZero'. However, since it's about the only example of a > "two-level deep" subtype nesting in your module, I'm going to use it
in Show quoted text
> this code example: > > package Dummy::MooseLike::Test; > use v5.10; > use Moo; > use MooX::Types::MooseLike::Numeric qw(:all); > no strict 'refs'; > > has 'Test_SingleDigit' => ( > is => 'rw', > isa => SingleDigit, > ); > > package main; > > my $obj = Dummy::MooseLike::Test->new(); > $obj->Test_SingleDigit(-2.5); > > ==================== > > So, it passes SingleDigit, and then passes NegativeIntOrZero, but it > doesn't pass Int. However, Int is never checked, and so the value is > "valid" without any errors.
Yeah, that should be a subtype of PositiveIntOrZero. Thanks for catching that.
On Wed Jun 27 17:13:51 2012, BBYRD wrote: Show quoted text
> https://metacpan.org/source/MATEU/MooX-Types-MooseLike- > 0.05/lib/MooX/Types/MooseLike.pm > > Oooo, this is a simple fix: > > is_type => sub { $full_test->($_[0]) }, > > > Instead of just $test. Also, *.t updates. I have an extensive test > plan that found this, if you're interested: > > https://github.com/SineSwiper/MooX-Types-CLike/blob/master/t/types.t
Nice! I have corrected the is_type to use the $full_test, thank you kindly.