4 # test method calls and autoloading.
17 print "# got `$_[0]', expected `$_[1]'\nnot " unless $_[0] eq $_[1];
18 # print "not " unless shift eq shift;
19 print "ok ", ++$cnt, "\n"
22 test( A->d, "C::d"); # Update hash table;
24 *B::d = \&D::d; # Import now.
25 test (A->d, "D::d"); # Update hash table;
27 eval 'sub B::d {"B::d1"}'; # Import now.
28 test (A->d, "B::d1"); # Update hash table;
30 undef &B::d; # Should work without any help too
33 eval 'sub B::d {"B::d2"}'; # Import now.
34 test (A->d, "B::d2"); # Update hash table;
36 # What follows is hardly guarantied to work, since the names in scripts
37 # are already linked to "pruned" globs. Say, `undef &B::d' if it were
38 # after `delete $B::{d}; sub B::d {}' would reach an old subroutine.
42 test (A->d, "C::d"); # Update hash table;
44 eval 'sub B::d {"B::d3"}'; # Import now.
45 test (A->d, "B::d3"); # Update hash table;
48 *dummy::dummy = sub {}; # Mark as updated
51 eval 'sub B::d {"B::d4"}'; # Import now.
52 test (A->d, "B::d4"); # Update hash table;
54 delete $B::{d}; # Should work without any help too
67 my $method = $B::AUTOLOAD;
68 *$B::AUTOLOAD = sub { "B: In $method, $c" };
73 my $method = $C::AUTOLOAD;
74 *$C::AUTOLOAD = sub { "C: In $method, $c" };
79 test(A->e(), "C: In C::e, 1"); # We get a correct autoload
80 test(A->e(), "C: In C::e, 1"); # Which sticks
82 test(A->ee(), "B: In A::ee, 2"); # We get a generic autoload, method in top
83 test(A->ee(), "B: In A::ee, 2"); # Which sticks
85 test(Y->f(), "B: In Y::f, 3"); # We vivify a correct method
86 test(Y->f(), "B: In Y::f, 3"); # Which sticks
88 # This test is not intended to be reasonable. It is here just to let you
89 # know that you broke some old construction. Feel free to rewrite the test
90 # if your patch breaks it.
94 my $method = $main::__ANON__;
95 *$main::__ANON__ = sub { "new B: In $method, $c" };
96 goto &$main::__ANON__;
99 test(A->eee(), "new B: In A::eee, 4"); # We get a correct $autoload
100 test(A->eee(), "new B: In A::eee, 4"); # Which sticks