Skip to content

Commit

Permalink
Added singleton() class param test file
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Sep 12, 2022
1 parent a8bd1e2 commit 3b99267
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions t/78-singleton_class.t
@@ -0,0 +1,47 @@
use warnings;
use strict;

use IPC::Shareable;
use Test::More;

BEGIN {
if (! $ENV{CI_TESTING}) {
plan skip_all => "Not on a legit CI platform...";
}
}

warn "Segs Before: " . IPC::Shareable::ipcs() . "\n" if $ENV{PRINT_SEGS};

# bad param

my $ok = eval { IPC::Shareable::singleton(); 1 };
is $ok, undef, "singleton() croaks if no GLUE param sent in";
like $@, qr/GLUE parameter/, "...and error is sane";

# singleton no exit notice

my ($proc, $warning);

{
local $SIG{__WARN__} = sub {$warning = shift;};

$proc = IPC::Shareable::singleton('LOCK');

is $proc, $$, "Class param is added if called in IPC::Shareable::singleton() format";

$proc = -1;

is $proc, -1, "\$proc set to -1 ok";

$proc = IPC::Shareable::singleton('LOCK');
}

END {
is $proc, -1, "singleton() on second call doesn't return anything ok";
is $warning, undef, "singleton outputs no warnings by default";

IPC::Shareable::_end;
warn "Segs After: " . IPC::Shareable::ipcs() . "\n" if $ENV{PRINT_SEGS};

done_testing;
};

0 comments on commit 3b99267

Please sign in to comment.