#!./perl
BEGIN {
chdir
't'
if
-d
't'
;
require
'./test.pl'
;
set_up_inc(
'../lib'
);
}
use
open
qw( :utf8 :std )
;
plan (84);
sub
expected {
my
(
$object
,
$package
,
$type
) =
@_
;
print
"# $object $package $type\n"
;
is(
ref
(
$object
),
$package
);
my
$r
=
qr/^\Q$package\E=(\w+)\(0x([0-9a-f]+)\)$/
u;
like(
"$object"
,
$r
);
if
(
"$object"
=~
$r
) {
is($1,
$type
);
cmp_ok(
do
{
no
warnings
'portable'
;
hex
($2)},
'=='
,
$object
);
}
else
{
fail(); fail();
}
}
$a1
=
bless
{},
"ዐ"
;
expected(
$a1
,
"ዐ"
,
"HASH"
);
$b1
=
bless
[],
"B"
;
expected(
$b1
,
"B"
,
"ARRAY"
);
$c1
=
bless
\(
map
"$_"
,
"test"
),
"ᶜ"
;
expected(
$c1
,
"ᶜ"
,
"SCALAR"
);
$t
èst =
"foo"
;
$d1
=
bless
\
*t
èst,
"ɖ"
;
expected(
$d1
,
"ɖ"
,
"GLOB"
);
$e1
=
bless
sub
{ 1 },
"ಎ"
;
expected(
$e1
,
"ಎ"
,
"CODE"
);
$f1
=
bless
\[],
"ḟ"
;
expected(
$f1
,
"ḟ"
,
"REF"
);
$g1
=
bless
\
substr
(
"test"
, 1, 2),
"ㄍ"
;
expected(
$g1
,
"ㄍ"
,
"LVALUE"
);
expected(
bless
(\
$a1
,
"ḟ"
),
"ḟ"
,
"REF"
);
expected(
$a1
,
"ዐ"
,
"HASH"
);
bless
$a1
,
"ዐ2"
;
expected(
$a1
,
"ዐ2"
,
"HASH"
);
{
local
$a1
=
bless
$a1
,
"ዐ3"
;
local
$b1
=
bless
[],
"B3"
;
my
$c1
=
bless
$c1
,
"ᶜ3"
;
our
$test2
=
""
;
my
$d1
=
bless
\
*test2
,
"ɖ3"
;
expected(
$a1
,
"ዐ3"
,
"HASH"
);
expected(
$b1
,
"B3"
,
"ARRAY"
);
expected(
$c1
,
"ᶜ3"
,
"SCALAR"
);
expected(
$d1
,
"ɖ3"
,
"GLOB"
);
}
expected(
$a1
,
"ዐ3"
,
"HASH"
);
expected(
$b1
,
"B"
,
"ARRAY"
);
expected(
$c1
,
"ᶜ3"
,
"SCALAR"
);
expected(
$d1
,
"ɖ"
,
"GLOB"
);
"ಎ"
=~ /(.)/;
expected(
bless
({}, $1),
"ಎ"
,
"HASH"
);
{
local
$! = 1;
my
$string
=
"$!"
;
$! = 2;
$! = 1;
expected(
bless
({}, $!),
$string
,
"HASH"
);
{
{
package
ḟ;
sub
test { main::is(${
$_
[0]},
$string
) }
}
$! = 2;
$f1
=
bless
\$!,
"ḟ"
;
$! = 1;
$f1
->test;
}
}
$a1
=
bless
{},
"ዐ4"
;
$b1
=
eval
{
bless
{},
$a1
};
isnt ($@,
''
,
"class is a ref"
);
{
my
%h
= 1..2;
my
(
$k
) =
keys
%h
;
my
$x
=\
$k
;
bless
$x
,
'pàm'
;
is(
ref
$x
,
'pàm'
);
my
$a
=
bless
\(
keys
%h
),
'zàp'
;
is(
ref
$a
,
'zàp'
);
}