use
lib
qw( ./lib ./t/lib ../inc ./inc )
;
my
$a
=
do
{
our
@ISA
=
qw(Tie::StdArray)
;
tie
my
(
@A
), __PACKAGE__;
\
@A
;
};
my
$h
=
do
{
our
@ISA
=
qw(Tie::StdHash)
;
tie
my
(
%H
), __PACKAGE__;
\
%H
};
my
$S
;
my
$s
=
do
{
our
@ISA
=
qw(Tie::StdScalar)
;
tie
$S
, __PACKAGE__;
\
$S
;
};
should_pass(
$a
, Tied);
should_pass(
$h
, Tied);
should_pass(
$s
, Tied);
should_fail(
$S
, Tied);
should_pass(
$a
, Tied[
"MyTie::Array"
]);
should_fail(
$h
, Tied[
"MyTie::Array"
]);
should_fail(
$s
, Tied[
"MyTie::Array"
]);
should_fail(
$a
, Tied[
"MyTie::Hash"
]);
should_pass(
$h
, Tied[
"MyTie::Hash"
]);
should_fail(
$s
, Tied[
"MyTie::Hash"
]);
should_fail(
$a
, Tied[
"MyTie::Scalar"
]);
should_fail(
$h
, Tied[
"MyTie::Scalar"
]);
should_pass(
$s
, Tied[
"MyTie::Scalar"
]);
should_pass(
$a
, Tied[ class_type
MyTieArray
=> {
class
=>
"MyTie::Array"
} ]);
should_fail(
$h
, Tied[ class_type
MyTieArray
=> {
class
=>
"MyTie::Array"
} ]);
should_fail(
$s
, Tied[ class_type
MyTieArray
=> {
class
=>
"MyTie::Array"
} ]);
should_fail(
$a
, Tied[ class_type
MyTieHash
=> {
class
=>
"MyTie::Hash"
} ]);
should_pass(
$h
, Tied[ class_type
MyTieHash
=> {
class
=>
"MyTie::Hash"
} ]);
should_fail(
$s
, Tied[ class_type
MyTieHash
=> {
class
=>
"MyTie::Hash"
} ]);
should_fail(
$a
, Tied[ class_type
MyTieScalar
=> {
class
=>
"MyTie::Scalar"
} ]);
should_fail(
$h
, Tied[ class_type
MyTieScalar
=> {
class
=>
"MyTie::Scalar"
} ]);
should_pass(
$s
, Tied[ class_type
MyTieScalar
=> {
class
=>
"MyTie::Scalar"
} ]);
my
$intersection
= (Tied) & (HashRef);
should_pass(
$h
,
$intersection
);
should_fail(
$a
,
$intersection
);
should_fail(
$s
,
$intersection
);
should_fail({
foo
=>2},
$intersection
);
my
$e
= exception { Tied[{}] };
like(
$e
,
qr/^Parameter to Tied\[.a\] expected to be a class name/
,
'weird exception'
);
done_testing;