summaryrefslogtreecommitdiffstats
path: root/t/impl-selection/bug-rt-78272.t
blob: dc74922b4ca9d32d1692a36e6d61619b7dbe19ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Fatal;

# https://rt.cpan.org/Public/Bug/Display.html?id=78272
my $e = $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP; exit 1";

like(
    exception { require Package::Stash },
    qr/$e is not a valid implementation for Package::Stash/,
    'Arbitrary code in $ENV throws exception'
);

like(
    exception {
        delete $INC{'Package/Stash.pm'};
        require Package::Stash;
    },
    qr/$e is not a valid implementation for Package::Stash/,
    'Sanity check: forcing package reload throws the exception again'
);

is(
    exception {
        $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP";
        delete $INC{'Package/Stash.pm'};
        require Package::Stash;
        new_ok(
            'Package::Stash' => ['Foo'],
            'Loaded and able to create instances'
        );
    },
    undef,
    'Valid $ENV value loads correctly'
);

done_testing;