From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

=pod
=encoding utf-8
=head1 PURPOSE
Test that inlined type checks don't generate issuing warning when compiled
in packages that override built-ins.
=head1 SEE ALSO
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT AND LICENCE
This software is copyright (c) 2020-2025 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
use strict;
use Test::Requires { 'Test::Warnings' => 0.005 };
{
package Local::Dummy1;
use Test::Requires 'Moo';
use Test::Requires 'MooX::TypeTiny';
}
BEGIN { $ENV{PERL_ONLY} = 1 }; # no XS
{
package Foo;
use Moo;
use Types::Standard qw(HashRef Str);
has _data => (
is => 'ro',
isa => HashRef[Str],
required => 1,
init_arg => 'data',
);
sub values {
@_==1 or die 'too many parameters';
CORE::values %{shift->_data};
}
sub keys {
@_==1 or die 'too many parameters';
CORE::keys %{shift->_data};
}
}
my $obj = Foo->new(data => {foo => 42});
print "$_\n" for $obj->values;
ok 1;
done_testing;