Blame t/SI_reinstall.t

Packit 1c5632
use Sub::Install;
Packit 1c5632
Sub::Install::install_installers('UNIVERSAL');
Packit 1c5632
Packit 1c5632
# This test, from here on out, is the verbatim "reinstall.t" test from
Packit 1c5632
# Sub::Installer 0.0.2
Packit 1c5632
Packit 1c5632
use Test::More 'no_plan';
Packit 1c5632
use Scalar::Util qw/reftype/;
Packit 1c5632
use warnings;
Packit 1c5632
Packit 1c5632
# Install a sub in a package...
Packit 1c5632
Packit 1c5632
my $sub_ref = main->reinstall_sub({ ok1 => \&ok });
Packit 1c5632
Packit 1c5632
is reftype $sub_ref, 'CODE'                  => 'reinstall returns code ref';
Packit 1c5632
Packit 1c5632
is_deeply \&ok, $sub_ref                 => 'reinstall returns correct code ref';
Packit 1c5632
Packit 1c5632
ok1(1                                    => 'reinstalled sub runs');
Packit 1c5632
Packit 1c5632
Packit 1c5632
# Install the same sub in the same package...
Packit 1c5632
Packit 1c5632
$SIG{__WARN__} = sub { ok 0 => "warned unexpected: @_" if $_[0] =~ /redefined/ };
Packit 1c5632
Packit 1c5632
$sub_ref = main->reinstall_sub({ ok1 => \&is });
Packit 1c5632
Packit 1c5632
is reftype $sub_ref, 'CODE'                  => 'reinstall2 returns code ref';
Packit 1c5632
Packit 1c5632
is_deeply \&is, $sub_ref                 => 'reinstall2 returns correct code ref';
Packit 1c5632
Packit 1c5632
ok1(1,1                                  => 'reinstalled sub reruns');
Packit 1c5632
Packit 1c5632
# Install in another package...
Packit 1c5632
Packit 1c5632
$sub_ref = Other->reinstall_sub({ ok2 => \&ok });
Packit 1c5632
Packit 1c5632
is reftype $sub_ref, 'CODE'                  => 'reinstall2 returns code ref';
Packit 1c5632
Packit 1c5632
is_deeply \&ok, $sub_ref                 => 'reinstall2 returns correct code ref';
Packit 1c5632
Packit 1c5632
ok1(1,1                                  => 'reinstalled sub reruns');
Packit 1c5632
Packit 1c5632
package Other;
Packit 1c5632
Packit 1c5632
ok2(1                                    => 'remotely reinstalled sub runs');