This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A plethora of isarev tests
[perl5.git] / t / mro / isarev.t
CommitLineData
14931424
FC
1#!./perl
2
3BEGIN {
4 unless (-d 'blib') {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
8 require q(./test.pl);
9}
10
11use strict;
12use warnings;
fb013ae2 13plan(tests => 15);
14931424
FC
14
15use mro;
16
17sub i {
fb013ae2
FC
18 my @args = @_;
19 @_
20 = (
21 join(" ", sort @{mro::get_isarev $args[0]}),
22 join(" ", sort @args[1..$#args-1]),
23 pop @args
24 );
14931424
FC
25 goto &is;
26}
27
28$::TODO = "[perl #75176] isarev leeks (and onions)";
29
30@Huskey::ISA = "Dog";
31@Dog::ISA = "Canid";
fb013ae2 32@Wolf::ISA = "Canid";
14931424
FC
33@Some::Brand::Name::ISA = "Dog::Bone";
34@Dog::Bone::ISA = "Treat";
fb013ae2 35@Free::Time::ISA = "Treat";
14931424
FC
36@MyCollar::ISA = "Dog::Collar::Leather";
37@Dog::Collar::Leather::ISA = "Collar";
fb013ae2
FC
38@Another::Collar::ISA = "Collar";
39*Tike:: = *Dog::;
14931424 40delete $::{"Dog::"};
fb013ae2
FC
41i Canid=>qw[ Wolf Tike ],
42 "deleting a stash elem updates isarev entries";
43i Treat=>qw[ Free::Time Tike::Bone ],
44 "deleting a nested stash elem updates isarev entries";
45i Collar=>qw[ Another::Collar Tike::Collar::Leather ],
46 "deleting a doubly nested stash elem updates isarev entries";
47
48@Goat::ISA = "Ungulate";
49@Goat::Dairy::ISA = "Goat";
50@Goat::Dairy::Toggenburg::ISA = "Goat::Dairy";
51@Weird::Thing::ISA = "g";
52*g:: = *Goat::;
53i Goat => qw[ Goat::Dairy Goat::Dairy::Toggenburg Weird::Thing ],
54 "isarev includes subclasses of aliases";
55delete $::{"g::"};
56i Ungulate => qw[ Goat Goat::Dairy Goat::Dairy::Toggenburg ],
57 "deleting an alias to a package updates isarev entries";
58i"Goat" => qw[ Goat::Dairy Goat::Dairy::Toggenburg ],
59 "deleting an alias to a package updates isarev entries of nested stashes";
60i"Goat::Dairy" => qw[ Goat::Dairy::Toggenburg ],
61 "deleting an stash alias updates isarev entries of doubly nested stashes";
62i g => qw [ Weird::Thing ],
63 "subclasses of the deleted alias become part of its isarev";
64
65@Caprine::ISA = "Hoofed::Mammal";
66@Caprine::Dairy::ISA = "Caprine";
67@Caprine::Dairy::Oberhasli::ISA = "Caprine::Dairy";
68@Whatever::ISA = "Caprine";
69*Caprid:: = *Caprine::;
70*Caprine:: = *Chevre::;
71i"Hoofed::Mammal" => qw[ Caprid ],
72 "replacing a stash updates isarev entries";
73i Caprine => qw[ Whatever ],
74 "replacing nested stashes updates isarev entries";
75
76@Disease::Eye::ISA = "Disease";
77@Disease::Eye::Infectious::ISA = "Disease::Eye";
78@Keratoconjunctivitis::ISA = "Disease::Ophthalmic::Infectious";
79*Disease::Ophthalmic:: = *Disease::Eye::;
80*Disease::Ophthalmic:: = *some_random_new_symbol::;
81i Disease => qw[ Disease::Eye ],
82 "replacing an alias of a stash updates isarev entries";
83i Caprine => qw[ Disease::Eye ],
84 "replacing an alias of a stash containing another updates isarev entries";
85i"some_random_new_symbol::Infectious" => qw[ Keratoconjunctivitis ],
86 "replacing an alias updates isarev of stashes nested in the replacement";
87
88# Globs ending with :: have autovivified stashes in them by default. We
89# want one without a stash.
90undef *Empty::;
91@Null::ISA = "Empty";
92@Null::Null::ISA = "Empty::Empty";
93{package Zilch::Empty} # autovivify it
94*Empty:: = *Zilch::;
95i Zilch => qw[ Null ], "assigning to an empty spot updates isarev";
96i"Zilch::Empty" => qw[ Null::Empty ],
97 "assigning to an empty spot updates isarev of nested packages";