Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use Type::Params 'compile', 'Invocant';
- use Types::Standard 'InstanceOf', 'Str', 'Int';
- use Test::MockObject;
- my $mock = Test::MockObject->new();
- use feature 'state';
- print foo($mock, 'bar');
- sub foo {
- state $check = compile( Invocant, Int );
- my ( $self, $id ) = $check->(@_);
- return $id . "_foo\n";
- }
- __END__
- Dies with error:
- Value "bar" did not pass type constraint "Int" (in $_[1]) at test.pl line 11
- "Int" is a subtype of "Num"
- "Num" is a subtype of "LaxNum"
- Value "bar" did not pass type constraint "LaxNum" (in $_[1])
- "LaxNum" is defined as: (defined($_) && !ref($_) && Scalar::Util::looks_like_number($_))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement