{
our
@inc
;
sub
import
{
my
(
$class
,
%args
) =
@_
;
unshift
@inc
,
$class
->generate_inc(
%args
);
}
}
{
sub
generate_inc {
return
'mylib'
}
}
{
sub
generate_inc {
return
'theirlib'
}
}
{
sub
generate_inc {
my
(
$class
,
%args
) =
@_
;
return
@{
$args
{dir}};
}
}
my
@tests
= (
[
'01 add to inc'
,
"[mylib]"
, [
'mylib'
] ],
[
'02 add to inc twice'
,
"[mylib]\n[mylib]"
, [
'mylib'
,
'mylib'
] ],
[
'03 add to inc from two plugins'
,
"[mylib]\n[theirlib]"
, [
'theirlib'
,
'mylib'
] ],
[
'04 add to inc with args'
,
"[multilib]\ndir=one\ndir=two\ndir=three"
, [
'one'
,
'two'
,
'three'
] ],
);
foreach
my
$test
(
@tests
) {
my
(
$name
,
$config
,
$expected
) =
@$test
;
my
$tempdir
= tempdir;
$CWD
=
$tempdir
;
write_file(
'lib.ini'
,
$config
);
lib::ini->
import
;
is_deeply \
@lib::ini::testplugin::inc
,
$expected
,
$name
;
undef
@lib::ini::testplugin::inc
;
}
done_testing;