1use Sub::Install; 2Sub::Install::install_installers('UNIVERSAL'); 3 4# This test, from here on out, is the verbatim "reinstall.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->reinstall_sub({ ok1 => \&ok }); 13 14is ref $sub_ref, 'CODE' => 'reinstall returns code ref'; 15 16is_deeply \&ok, $sub_ref => 'reinstall returns correct code ref'; 17 18ok1(1 => 'reinstalled sub runs'); 19 20 21# Install the same sub in the same package... 22 23$SIG{__WARN__} = sub { ok 0 => "warned unexpected: @_" if $_[0] =~ /redefined/ }; 24 25$sub_ref = main->reinstall_sub({ ok1 => \&is }); 26 27is ref $sub_ref, 'CODE' => 'reinstall2 returns code ref'; 28 29is_deeply \&is, $sub_ref => 'reinstall2 returns correct code ref'; 30 31ok1(1,1 => 'reinstalled sub reruns'); 32 33# Install in another package... 34 35$sub_ref = Other->reinstall_sub({ ok2 => \&ok }); 36 37is ref $sub_ref, 'CODE' => 'reinstall2 returns code ref'; 38 39is_deeply \&ok, $sub_ref => 'reinstall2 returns correct code ref'; 40 41ok1(1,1 => 'reinstalled sub reruns'); 42 43package Other; 44 45ok2(1 => 'remotely reinstalled sub runs'); 46