From: Vincent Pit Date: Tue, 20 Aug 2013 20:03:51 +0000 (-0300) Subject: Get rid of the indirect notation X-Git-Tag: v0.16~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=0b4f6d24128d9d60c3f8a5010e43bdfd9de7b655;p=perl%2Fmodules%2FIPC-MorseSignals.git Get rid of the indirect notation --- diff --git a/lib/IPC/MorseSignals.pm b/lib/IPC/MorseSignals.pm index 89232f3..99bd279 100644 --- a/lib/IPC/MorseSignals.pm +++ b/lib/IPC/MorseSignals.pm @@ -20,7 +20,7 @@ our $VERSION = '0.15'; # In the sender process use IPC::MorseSignals::Emitter; - my $deuce = new IPC::MorseSignals::Emitter speed => 1024; + my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024); $deuce->post('HLAGH') for 1 .. 3; $deuce->send($pid); @@ -30,9 +30,9 @@ our $VERSION = '0.15'; use IPC::MorseSignals::Receiver; local %SIG; - my $pants = new IPC::MorseSignals::Receiver \%SIG, done => sub { + my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { print STDERR "GOT $_[1]\n"; - }; + }); =head1 DESCRIPTION diff --git a/lib/IPC/MorseSignals/Emitter.pm b/lib/IPC/MorseSignals/Emitter.pm index 163e576..b5ba7e6 100644 --- a/lib/IPC/MorseSignals/Emitter.pm +++ b/lib/IPC/MorseSignals/Emitter.pm @@ -26,7 +26,7 @@ our $VERSION = '0.15'; use IPC::MorseSignals::Emitter; - my $deuce = new IPC::MorseSignals::Emitter speed => 1024; + my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024); $deuce->post('HLAGH') for 1 .. 3; $deuce->send($pid); diff --git a/lib/IPC/MorseSignals/Receiver.pm b/lib/IPC/MorseSignals/Receiver.pm index cc63e4b..b14b676 100644 --- a/lib/IPC/MorseSignals/Receiver.pm +++ b/lib/IPC/MorseSignals/Receiver.pm @@ -25,9 +25,9 @@ our $VERSION = '0.15'; use IPC::MorseSignals::Receiver; local %SIG; - my $pants = new IPC::MorseSignals::Receiver \%SIG, done => sub { + my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { print STDERR "GOT $_[1]\n"; - }; + }); =head1 DESCRIPTION diff --git a/samples/try.pl b/samples/try.pl index 68388c8..f76d747 100755 --- a/samples/try.pl +++ b/samples/try.pl @@ -15,10 +15,10 @@ if (!defined $pid) { die "fork() failed : $!"; } elsif ($pid == 0) { local %SIG; - my $rcv = new IPC::MorseSignals::Receiver \%SIG, done => sub { + my $rcv = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { print STDERR "I, the child, recieved this : $_[1]\n"; exit EXIT_SUCCESS; - }; + }); print STDERR "I'm $$ (the child), and I'm waiting for data...\n"; pause while 1; exit EXIT_FAILURE; @@ -26,7 +26,7 @@ if (!defined $pid) { print STDERR "I'm $$ (the parent), and I'm gonna send a message to my child $pid.\n"; -my $snd = new IPC::MorseSignals::Emitter speed => 1000; +my $snd = IPC::MorseSignals::Emitter->new(speed => 1000); $snd->post("This message was sent with IPC::MorseSignals"); $snd->send($pid); waitpid $pid, 0; diff --git a/t/20-emitter-obj.t b/t/20-emitter-obj.t index bd88b12..abb01b4 100644 --- a/t/20-emitter-obj.t +++ b/t/20-emitter-obj.t @@ -9,7 +9,7 @@ use IPC::MorseSignals::Emitter; sub neq { abs($_[0] - $_[1]) < ($_[1] / 10) }; -my $deuce = new IPC::MorseSignals::Emitter; +my $deuce = IPC::MorseSignals::Emitter->new; ok(defined $deuce, 'BME object is defined'); is(ref $deuce, 'IPC::MorseSignals::Emitter', 'IME object is valid'); ok($deuce->isa('Bit::MorseSignals::Emitter'), 'IME is a BME'); @@ -32,22 +32,22 @@ $deuce->speed(100); is($deuce->speed, 100, 'set speed is 100'); ok(neq($deuce->delay, 0.01), 'resulting speed is 0.01'); -$deuce = new IPC::MorseSignals::Emitter delay => 0.25; +$deuce = IPC::MorseSignals::Emitter->new(delay => 0.25); ok(neq($deuce->delay, 0.25), 'initial delay is 0.25'); is($deuce->speed, 4, 'resulting initial speed is 4'); -$deuce = new IPC::MorseSignals::Emitter speed => 40; +$deuce = IPC::MorseSignals::Emitter->new(speed => 40); is($deuce->speed, 40, 'initial speed is 40'); ok(neq($deuce->delay, 0.025), 'resulting initial delay is 0.025'); -$deuce = new IPC::MorseSignals::Emitter delay => 0.25, speed => 40; +$deuce = IPC::MorseSignals::Emitter->new(delay => 0.25, speed => 40); ok(neq($deuce->delay, 0.25), 'delay supersedes speed'); -$deuce = new IPC::MorseSignals::Emitter delay => 0; +$deuce = IPC::MorseSignals::Emitter->new(delay => 0); is($deuce->delay, 1, 'wrong delay results in 1'); -$deuce = new IPC::MorseSignals::Emitter speed => 0.1; +$deuce = IPC::MorseSignals::Emitter->new(speed => 0.1); is($deuce->delay, 1, 'wrong speed results in 1'); -$deuce = new IPC::MorseSignals::Emitter delay => 0, speed => -0.1; +$deuce = IPC::MorseSignals::Emitter->new(delay => 0, speed => -0.1); is($deuce->delay, 1, 'wrong delay and speed result in 1'); diff --git a/t/30-receiver-obj.t b/t/30-receiver-obj.t index 855a9d0..35aadd4 100644 --- a/t/30-receiver-obj.t +++ b/t/30-receiver-obj.t @@ -7,7 +7,7 @@ use Test::More tests => 4; use IPC::MorseSignals::Receiver; -my $pants = new IPC::MorseSignals::Receiver \%SIG; +my $pants = IPC::MorseSignals::Receiver->new(\%SIG); ok(defined $pants, 'IMR object is defined'); is(ref $pants, 'IPC::MorseSignals::Receiver', 'IMR object is valid'); ok($pants->isa('Bit::MorseSignals::Receiver'), 'IMR is a BMR'); diff --git a/t/50-self-plain.t b/t/50-self-plain.t index 06c0a60..df5c272 100644 --- a/t/50-self-plain.t +++ b/t/50-self-plain.t @@ -11,11 +11,11 @@ use IPC::MorseSignals::Receiver; my @msgs = qw/hlagh hlaghlaghlagh HLAGH HLAGHLAGHLAGH \x{0dd0}\x{00} h\x{00}la\x{00}gh \x{00}\x{ff}\x{ff}\x{00}\x{00}\x{ff}/; -my $deuce = new IPC::MorseSignals::Emitter speed => 1024; -my $pants = new IPC::MorseSignals::Receiver \%SIG, done => sub { +my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024); +my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { my $cur = shift @msgs; is($_[1], $cur, "message correctly received"); -}; +}); $deuce->post($_) for @msgs; $deuce->send($$); diff --git a/t/51-self-utf8.t b/t/51-self-utf8.t index 1b69273..5379b71 100644 --- a/t/51-self-utf8.t +++ b/t/51-self-utf8.t @@ -14,11 +14,11 @@ my @msgs = qw/€éèë 月語 x tata たTÂ/; sub cp { join '.', map ord, split //, $_[0] } -my $deuce = new IPC::MorseSignals::Emitter speed => 1024; -my $pants = new IPC::MorseSignals::Receiver \%SIG, done => sub { +my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024); +my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { my $cur = shift @msgs; ok($_[1] eq $cur, 'got ' . cp($_[1]) . ', expected ' . cp($cur)) -}; +}); $deuce->post($_) for @msgs; $deuce->send($$); diff --git a/t/52-self-storable.t b/t/52-self-storable.t index 6f3933c..138dd8e 100644 --- a/t/52-self-storable.t +++ b/t/52-self-storable.t @@ -19,11 +19,11 @@ my @msgs = ( $msgs[7]->{wut} = { dong => [ 0 .. 9 ], recurse => $msgs[7] }; my $i = 0; -my $deuce = new IPC::MorseSignals::Emitter speed => 1024; -my $pants = new IPC::MorseSignals::Receiver \%SIG, done => sub { +my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024); +my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { my $cur = shift @msgs; is_deeply($_[1], $cur, 'got object ' . $i++); -}; +}); $deuce->post($_) for @msgs; $deuce->send($$); diff --git a/t/lib/IPC/MorseSignals/TestSuite.pm b/t/lib/IPC/MorseSignals/TestSuite.pm index 570fa27..5b95eef 100644 --- a/t/lib/IPC/MorseSignals/TestSuite.pm +++ b/t/lib/IPC/MorseSignals/TestSuite.pm @@ -34,11 +34,11 @@ sub spawn { close $rdr or die "close() failed: $!"; select $wtr; $| = 1; - my $rcv = new IPC::MorseSignals::Receiver \%SIG, done => sub { + my $rcv = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { my $msg = Dumper($_[1]); $msg =~ s/\n\r/ /g; print $wtr "$msg\n"; - }; + }); $SIG{__WARN__} = sub { my $warn = join '', @_; $warn =~ s/\n\r/ /g; @@ -86,7 +86,7 @@ sub init { sub cleanup { slaughter } -my $snd = new IPC::MorseSignals::Emitter; +my $snd = IPC::MorseSignals::Emitter->new; sub try { my ($msg) = @_;