File: SI_reinstall.t

package info (click to toggle)
libsub-install-perl 0.929-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 281; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use Sub::Install;
Sub::Install::install_installers('UNIVERSAL');

# This test, from here on out, is the verbatim "reinstall.t" test from
# Sub::Installer 0.0.2

use Test::More 'no_plan';
use Scalar::Util qw/reftype/;
use warnings;

# Install a sub in a package...

my $sub_ref = main->reinstall_sub({ ok1 => \&ok });

is reftype $sub_ref, 'CODE'                  => 'reinstall returns code ref';

is_deeply \&ok, $sub_ref                 => 'reinstall returns correct code ref';

ok1(1                                    => 'reinstalled sub runs');


# Install the same sub in the same package...

$SIG{__WARN__} = sub { ok 0 => "warned unexpected: @_" if $_[0] =~ /redefined/ };

$sub_ref = main->reinstall_sub({ ok1 => \&is });

is reftype $sub_ref, 'CODE'                  => 'reinstall2 returns code ref';

is_deeply \&is, $sub_ref                 => 'reinstall2 returns correct code ref';

ok1(1,1                                  => 'reinstalled sub reruns');

# Install in another package...

$sub_ref = Other->reinstall_sub({ ok2 => \&ok });

is reftype $sub_ref, 'CODE'                  => 'reinstall2 returns code ref';

is_deeply \&ok, $sub_ref                 => 'reinstall2 returns correct code ref';

ok1(1,1                                  => 'reinstalled sub reruns');

package Other;

ok2(1                                    => 'remotely reinstalled sub runs');