This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate mainline
[perl5.git] / t / op / universal.t
index 2e31d78..7d5f59a 100755 (executable)
@@ -9,7 +9,7 @@ BEGIN {
     $| = 1;
 }
 
-print "1..93\n";
+print "1..98\n";
 
 $a = {};
 bless $a, "Bob";
@@ -59,6 +59,8 @@ $a = new Alice;
 test $a->isa("Alice");
 test $a->isa("main::Alice");    # check that alternate class names work
 
+test(("main::Alice"->new)->isa("Alice"));
+
 test $a->isa("Bob");
 test $a->isa("main::Bob");
 
@@ -172,3 +174,16 @@ test ! UNIVERSAL::isa("\xff\xff\xff\0", 'HASH');
     main::test can( "Pickup", "can" ) == \&UNIVERSAL::can;
     main::test VERSION "UNIVERSAL" ;
 }
+
+{
+    # test isa() and can() on magic variables
+    "Human" =~ /(.*)/;
+    test $1->isa("Human");
+    test $1->can("eat");
+    package HumanTie;
+    sub TIESCALAR { bless {} }
+    sub FETCH { "Human" }
+    tie my($x), "HumanTie";
+    ::test $x->isa("Human");
+    ::test $x->can("eat");
+}