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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
sub clear_load {
delete $Package::{'Stash::'};
delete $INC{'Package/Stash.pm'};
delete $INC{'Package/Stash/PP.pm'};
delete $INC{'Package/Stash/XS.pm'};
}
my $has_xs;
{
$has_xs = eval "require Package::Stash::XS; 1";
clear_load;
}
{
require Package::Stash;
warn $Package::Stash::IMPLEMENTATION;
is($Package::Stash::IMPLEMENTATION, $has_xs ? 'XS' : 'PP',
"autodetected properly");
can_ok('Package::Stash', 'new', "and got some methods");
clear_load;
}
{
$ENV{PACKAGE_STASH_IMPLEMENTATION} = 'PP';
require Package::Stash;
is($Package::Stash::IMPLEMENTATION, 'PP',
"autodetected properly");
can_ok('Package::Stash', 'new', "and got some methods");
clear_load;
}
SKIP: {
skip "no XS", 2 unless $has_xs;
$ENV{PACKAGE_STASH_IMPLEMENTATION} = 'XS';
require Package::Stash;
is($Package::Stash::IMPLEMENTATION, 'XS',
"autodetected properly");
can_ok('Package::Stash', 'new', "and got some methods");
clear_load;
}
{
$Package::Stash::IMPLEMENTATION = 'PP';
require Package::Stash;
is($Package::Stash::IMPLEMENTATION, 'PP',
"autodetected properly");
can_ok('Package::Stash', 'new', "and got some methods");
clear_load;
}
SKIP: {
skip "no XS", 2 unless $has_xs;
$Package::Stash::IMPLEMENTATION = 'XS';
require Package::Stash;
is($Package::Stash::IMPLEMENTATION, 'XS',
"autodetected properly");
can_ok('Package::Stash', 'new', "and got some methods");
clear_load;
}
done_testing;
|