Skip to content

Commit

Permalink
Updated tests, added POD for new()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Jul 28, 2021
1 parent 63d6ab2 commit d8c2d14
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Revision history for Perl extension IPC::Shareable.
- Fix significant bug where at least on MacOS, if we generated a CRC of a
key that was greater than 0x80000000, it would round down the key to that
number exactly, casuing duplicates, and incorrect segment access
- Added new()
- Added new() method, returns a reference (default hash) without having to
do the tie() directly

1.04 2021-06-28
- Skip unspawn tests for perls with -Duselongdouble, as Storable is not
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ t/00-base.t
t/02-create.t
t/04-key.t
t/05-sv.t
t/07-new.t
t/10-av.t
t/15-hv.t
t/17-attributes.t
Expand Down Expand Up @@ -52,6 +53,8 @@ t/93-manifest.t
t/_spawn
t/_spawn_class
t/SpawnTest.pm
testing/new_one.pl
testing/new_two.pl
testing/one_deep_hash.pl
testing/sharelite_with_sereal.pl
testing/two_deep_hash.pl
19 changes: 19 additions & 0 deletions lib/IPC/Shareable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ IPC::Shareable - Use shared memory backed variables across processes
use IPC::Shareable qw(:lock);
my $href = IPC::Shareable->new(%options);
# ...or
tie SCALAR, 'IPC::Shareable', OPTIONS;
tie ARRAY, 'IPC::Shareable', OPTIONS;
tie HASH, 'IPC::Shareable', OPTIONS;
Expand Down Expand Up @@ -1233,6 +1237,21 @@ Default values for options are:
=head1 METHODS
=head2 new
Instantiates and returns a reference to a hash backed by shared memory.
Parameters:
Hash, Optional: See the L</OPTIONS> section for a list of all available options.
Most often, you'll want to send in the B<key>, B<create> and B<destroy> options.
It is possible to get a reference to an array or scalar as well. Simply send in
either C<< var = > 'ARRAY' >> or C<< var => 'SCALAR' >> to do so.
Return: A reference to a hash (or array or scalar) which is backed by shared
memory.
=head2 singleton($glue, $warn)
Class method that ensures that only a single instance of a script can be run
Expand Down
2 changes: 1 addition & 1 deletion t/04-key.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use Test::More;
my $k = tie my $sv, 'IPC::Shareable', {key => 'TEST', create => 1, destroy => 1};

is $k->{attributes}{key}, 'TEST', "attr key is TEST ok";
is $k->seg->key, 4008350648 - 0x8000000 0, "four letter attr key is ok";
is $k->seg->key, 4008350648 - 0x80000000, "four letter attr key is ok";
}

# three letter lower case
Expand Down
3 changes: 2 additions & 1 deletion t/07-new.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if ($pid == 0) {
is $$ps, 'parent', 'parent set the scalar value ok';

IPC::Shareable->clean_up_all;

done_testing();
}

done_testing();

0 comments on commit d8c2d14

Please sign in to comment.