mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-22 03:44:55 +00:00
Fix for 1073532: Mo doesn't work with Scalar::Util::PP
Unlike Scalar::Util, Scalar::Util::PP::looks_like_number shifts @_, so calling it as &looks_like_number works differently in both versions; see https://rt.cpan.org/Public/Bug/Display.html?id=80525
This commit is contained in:
@@ -9,6 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use PerconaTest ();
|
||||
use Test::More;
|
||||
|
||||
sub dies_ok (&;$) {
|
||||
@@ -182,4 +183,19 @@ for my $type (@types[1..$#types]) {
|
||||
my $method = "my$type";
|
||||
dies_ok { $foo->$method(undef) } "$type attr set to undef dies" }
|
||||
|
||||
|
||||
use Config;
|
||||
use File::Spec;
|
||||
use IPC::Cmd ();
|
||||
my $thisperl = $^X;
|
||||
if ($^O ne 'VMS')
|
||||
{$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
|
||||
|
||||
my $pm_test = File::Spec->catfile($PerconaTest::trunk, qw(t lib Mo isa_subtest.pm));
|
||||
|
||||
ok(
|
||||
scalar(IPC::Cmd::run(command => [$thisperl, $pm_test])),
|
||||
"Mo types work with Scalar::Util::PP",
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
28
t/lib/Mo/isa_subtest.pm
Normal file
28
t/lib/Mo/isa_subtest.pm
Normal file
@@ -0,0 +1,28 @@
|
||||
BEGIN {
|
||||
require Scalar::Util::PP;
|
||||
*Scalar::Util:: = \*Scalar::Util::PP::;
|
||||
$INC{"Scalar/Util.pm"} = __FILE__;
|
||||
};
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
{
|
||||
package isa_subtest;
|
||||
use Mo;
|
||||
|
||||
has attr => (
|
||||
is => 'rw',
|
||||
isa => 'Int',
|
||||
);
|
||||
|
||||
1;
|
||||
}
|
||||
|
||||
isa_subtest->new(attr => 100);
|
Reference in New Issue
Block a user