Commit | Line | Data |
---|---|---|
44a8e56a | 1 | #!./perl |
2 | # | |
3 | # check UNIVERSAL | |
4 | # | |
5 | ||
ff0cee69 | 6 | print "1..11\n"; |
44a8e56a | 7 | |
8 | $a = {}; | |
9 | bless $a, "Bob"; | |
ff0cee69 | 10 | print "not " unless $a->isa("Bob"); |
11 | print "ok 1\n"; | |
44a8e56a | 12 | |
ff0cee69 | 13 | package Human; |
14 | sub eat {} | |
44a8e56a | 15 | |
ff0cee69 | 16 | package Female; |
17 | @ISA=qw(Human); | |
44a8e56a | 18 | |
ff0cee69 | 19 | package Alice; |
20 | @ISA=qw(Bob Female); | |
21 | sub drink {} | |
22 | sub new { bless {} } | |
44a8e56a | 23 | |
24 | package main; | |
ff0cee69 | 25 | $a = new Alice; |
44a8e56a | 26 | |
ff0cee69 | 27 | print "not " unless $a->isa("Alice"); |
28 | print "ok 2\n"; | |
44a8e56a | 29 | |
ff0cee69 | 30 | print "not " unless $a->isa("Bob"); |
31 | print "ok 3\n"; | |
44a8e56a | 32 | |
ff0cee69 | 33 | print "not " unless $a->isa("Female"); |
34 | print "ok 4\n"; | |
35 | ||
36 | print "not " unless $a->isa("Human"); | |
37 | print "ok 5\n"; | |
38 | ||
39 | print "not " if $a->isa("Male"); | |
40 | print "ok 6\n"; | |
41 | ||
42 | print "not " unless $a->can("drink"); | |
43 | print "ok 7\n"; | |
44 | ||
45 | print "not " unless $a->can("eat"); | |
46 | print "ok 8\n"; | |
44a8e56a | 47 | |
ff0cee69 | 48 | print "not " if $a->can("sleep"); |
49 | print "ok 9\n"; | |
44a8e56a | 50 | |
ff0cee69 | 51 | print "not " unless UNIVERSAL::isa([], "ARRAY"); |
52 | print "ok 10\n"; | |
44a8e56a | 53 | |
ff0cee69 | 54 | print "not " unless UNIVERSAL::isa({}, "HASH"); |
55 | print "ok 11\n"; |