BEGIN { plan
tests
=> 6 };
eval
"use Data::Compare"
;
my
$no_compare
= $@ ? 1 : 0;
END {
print
"not ok 1\n"
unless
$loaded
; }
$loaded
++;
ok(1);
ok(
ref
$Config::FreeForm::Foo
eq
"HASH"
);
my
$orig_conf
= { %{
$Config::FreeForm::Foo
} };
my
$t_conf
=
"./t.conf"
;
Config::FreeForm::rewrite(
'Foo'
,
$t_conf
);
ok(-e
$t_conf
);
my
$conf
=
do
$t_conf
;
if
(
$no_compare
) {
skip(
$no_compare
, 0);
}
else
{
ok(Compare(
$Config::FreeForm::Foo
,
$conf
->{Foo}));
}
unlink
$t_conf
or
die
"Can't remove $t_conf: $!"
;
$Config::FreeForm::Foo
->{foo} =
"bar"
;
my
$saved_conf
=
$Config::FreeForm::Foo
;
Config::FreeForm::rewrite(
'Foo'
);
$Config::FreeForm::Foo
= {};
Config::FreeForm::reload(
'Foo'
);
ok(
exists
$Config::FreeForm::Foo
->{foo});
if
(
$no_compare
) {
skip(
$no_compare
, 0);
}
else
{
ok(Compare(
$Config::FreeForm::Foo
,
$saved_conf
));
}
$Config::FreeForm::Foo
=
$orig_conf
;
Config::FreeForm::rewrite(
'Foo'
);