This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Encode to CPAN version 2.78
[perl5.git] / t / mro / isa_aliases.t
1 #!./perl
2
3 BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl' }
4
5 plan 13;
6
7 @Foogh::ISA = "Bar";
8 *Phoogh::ISA = *Foogh::ISA;
9 @Foogh::ISA = "Baz";
10
11 ok 'Foogh'->isa("Baz"),
12  'isa after another stash has claimed the @ISA via glob assignment';
13 ok 'Phoogh'->isa("Baz"),
14  'isa on the stash that claimed the @ISA via glob assignment';
15 ok !Foogh->isa("Bar"),
16  '!isa when another stash has claimed the @ISA via glob assignment';
17 ok !Phoogh->isa("Bar"),
18  '!isa on the stash that claimed the @ISA via glob assignment';
19
20 @Foogh::ISA = "Bar";
21 *Foogh::ISA = ["Baz"];
22
23 ok 'Foogh'->isa("Baz"),
24  'isa after glob-to-ref assignment when *ISA is shared';
25 ok 'Phoogh'->isa("Baz"),
26  'isa after glob-to-ref assignment on another stash when *ISA is shared';
27 ok !Foogh->isa("Bar"),
28  '!isa after glob-to-ref assignment when *ISA is shared';
29 ok !Phoogh->isa("Bar"),
30  '!isa after glob-to-ref assignment on another stash when *ISA is shared';
31
32 @Foo::ISA = "Bar";
33 *Phoo::ISA = \@Foo::ISA;
34 @Foo::ISA = "Baz";
35
36 ok 'Foo'->isa("Baz"),
37  'isa after another stash has claimed the @ISA via ref-to-glob assignment';
38 ok 'Phoo'->isa("Baz"),
39  'isa on the stash that claimed the @ISA via ref-to-glob assignment';
40 ok !Foo->isa("Bar"),
41  '!isa when another stash has claimed the @ISA via ref-to-glob assignment';
42 ok !Phoo->isa("Bar"),
43  '!isa on the stash that claimed the @ISA via ref-to-glob assignment';
44
45 *Fooo::ISA = *Baro::ISA;
46 @Fooo::ISA = "Bazo";
47 sub Bazo::ook { "Baz" }
48 sub L::ook { "See" }
49 Baro->ook;
50 local *Fooo::ISA = ["L"];
51 is 'Baro'->ook, 'See', 'localised *ISA=$ref assignment';