18 # First we must set up some autoloader files
19 mkdir $dir, 0755 or die "Can't mkdir $dir: $!";
20 mkdir "$dir${sep}auto", 0755 or die "Can't mkdir: $!";
21 mkdir "$dir${sep}auto${sep}Foo", 0755 or die "Can't mkdir: $!";
23 open(FOO, ">$dir${sep}auto${sep}Foo${sep}foo.al") or die;
26 sub foo { shift; shift || "foo" }
31 open(BAR, ">$dir${sep}auto${sep}Foo${sep}bar.al") or die;
34 sub bar { shift; shift || "bar" }
39 open(BAZ, ">$dir${sep}auto${sep}Foo${sep}bazmarkhian.al") or die;
42 sub bazmarkhianish { shift; shift || "baz" }
47 # Let's define the package
52 sub new { bless {}, shift };
58 print "not " unless $foo->foo eq 'foo'; # autoloaded first time
61 print "not " unless $foo->foo eq 'foo'; # regular call
64 # Try an undefined method
68 print "not " unless $@ =~ /^Can't locate/;
71 # Used to be trouble with this
76 print "not " unless $@ =~ /oops/;
79 # Pass regular expression variable to autoloaded function. This used
80 # to go wrong because AutoLoader used regular expressions to generate
81 # autoloaded filename.
83 print "not " unless $1 eq 'foo';
86 print "not " unless $foo->bar($1) eq 'foo';
89 print "not " unless $foo->bar($1) eq 'foo';
92 print "not " unless $foo->bazmarkhianish($1) eq 'foo';
95 print "not " unless $foo->bazmarkhianish($1) eq 'foo';
98 # test recursive autoloads
99 open(F, ">$dir${sep}auto${sep}Foo${sep}a.al") or die;
103 sub a { print "ok 11\n"; }
108 open(F, ">$dir${sep}auto${sep}Foo${sep}b.al") or die;
111 sub b { print "ok 10\n"; }
119 return unless $dir && -d $dir;
120 unlink "$dir${sep}auto${sep}Foo${sep}foo.al";
121 unlink "$dir${sep}auto${sep}Foo${sep}bar.al";
122 unlink "$dir${sep}auto${sep}Foo${sep}bazmarkhian.al";
123 unlink "$dir${sep}auto${sep}Foo${sep}a.al";
124 unlink "$dir${sep}auto${sep}Foo${sep}b.al";
125 rmdir "$dir${sep}auto${sep}Foo";
126 rmdir "$dir${sep}auto";