This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
3e075cff43caa38ef5a38feecb55090e61abbeed
[perl5.git] / t / op / universal.t
1 #!./perl
2 #
3 # check UNIVERSAL
4 #
5
6 print "1..4\n";
7
8 # explicit bless
9
10 $a = {};
11 bless $a, "Bob";
12 if ($a->class eq "Bob") {print "ok 1\n";} else {print "not ok 1\n";}
13
14 # bless through a package
15
16 package Fred;
17
18 $b = {};
19 bless $b;
20 if ($b->class eq "Fred") {print "ok 2\n";} else {print "not ok 2\n";}
21
22 package main;
23
24 # same as test 1 and 2, but with other object syntax
25
26 # explicit bless
27
28 $a = {};
29 bless $a, "Bob";
30 if (class $a eq "Bob") {print "ok 3\n";} else {print "not ok 3\n";}
31
32 # bless through a package
33
34 package Fred;
35
36 $b = {};
37 bless $b;
38 if (class $b eq "Fred") {print "ok 4\n";} else {print "not ok 4\n";}