Params-Util

 view release on metacpan or  search on metacpan

t/pp/06_invocant.t  view on Meta::CPAN

my @data = (             # I
    [undef, 0, 'undef'],
    [
        1000 => 0,
        '1000'
    ],
    [
        $unpkg => 1,
        qq("$unpkg")
    ],
    [
        $pkg => 1,
        qq("$pkg")
    ],
    [
        [] => 0,
        '[]'
    ],
    [
        {} => 0,
        '{}'
    ],
    [
        $object => 1,
        'blessed reference'
    ],
    [
        $false_obj1 => 1,
        'blessed reference'
    ],
    [
        $tied => 1,
        'tied value'
    ],
);

for my $datum (@data)
{
    is(_INVOCANT($datum->[0]) ? 1 : 0, $datum->[1], "$datum->[2] " . ($datum->[1] ? 'is' : "isn't") . " _IN");
}

# Skip the most evil test except on automated testing, because it
# fails on at least one common production OS (RedHat Enterprise Linux 4)
# and the test case should be practically impossible to encounter
# in real life. The damage the bug could cause users in production is
# far lower than the damage caused by Params::Util failing to install.
SKIP:
{
    unless ($ENV{AUTOMATED_TESTING})
    {
        skip("Skipping nasty test unless AUTOMATED_TESTING", 1);
    }
    ok(!!_INVOCANT($false_obj2), 'Testing null class as an invocant');
}

package Params::Util::Test::_INVOCANT::Tied;

sub TIESCALAR
{
    my ($class, $value) = @_;
    return bless \$value => $class;
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 3.494 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )