1use Sub::Install; 2Sub::Install::install_installers('UNIVERSAL'); 3 4# This test, from here on out, is the verbatim "install.t" test from 5# Sub::Installer 0.0.2 6 7use Test::More 'no_plan'; 8use warnings; 9 10# Install a sub in a package... 11 12my $sub_ref = main->install_sub({ ok1 => \&ok }); 13 14is ref $sub_ref, 'CODE' => 'install returns code ref'; 15 16is_deeply \&ok, $sub_ref => 'install returns correct code ref'; 17 18ok1(1 => 'installed sub runs'); 19 20 21# Install the same sub in the same package... 22 23$SIG{__WARN__} = sub { ok 1 => 'warned as expected' if $_[0] =~ /redefined/ }; 24 25 26$sub_ref = main->install_sub({ ok1 => \&is }); 27 28is ref $sub_ref, 'CODE' => 'install2 returns code ref'; 29 30is_deeply \&is, $sub_ref => 'install2 returns correct code ref'; 31 32ok1(1,1 => 'installed sub reruns'); 33 34# Install in another package... 35 36$sub_ref = Other->install_sub({ ok2 => \&ok }); 37 38is ref $sub_ref, 'CODE' => 'install2 returns code ref'; 39 40is_deeply \&ok, $sub_ref => 'install2 returns correct code ref'; 41 42ok1(1,1 => 'installed sub reruns'); 43 44package Other; 45 46ok2(1 => 'remotely installed sub runs'); 47