use Bit::MorseSignals::Emitter;
use Bit::MorseSignals::Receiver;
- my $deuce = new Bit::MorseSignals::Emitter;
- my $pants = new Bit::MorseSignals::Receiver done => sub { print $_[1], "\n" };
+ my $deuce = Bit::MorseSignals::Emitter->new;
+ my $pants = Bit::MorseSignals::Receiver->new(done => sub { print $_[1], "\n" });
$deuce->post('HLAGH') for 1 .. 3;
$pants->push while defined ($_ = $deuce->pop);
use Bit::MorseSignals::Emitter;
- my $deuce = new Bit::MorseSignals::Emitter;
+ my $deuce = Bit::MorseSignals::Emitter->new;
$deuce->post("hlagh") for 1 .. 3;
while (defined(my $bit = $deuce->pop)) {
sends_by_some_mean_lets_say_signals($bit);
use Bit::MorseSignals::Receiver;
- my $pants = new Bit::MorseSignals::Receiver done => sub { print "received $_[1]!\n" };
+ my $pants = Bit::MorseSignals::Receiver->new(done => sub { print "received $_[1]!\n" });
while (...) {
my $bit = comes_from_somewhere_lets_say_signals();
$pants->push($bit);
use Bit::MorseSignals::Emitter;
-my $deuce = new Bit::MorseSignals::Emitter;
+my $deuce = Bit::MorseSignals::Emitter->new;
ok(defined $deuce, 'BME object is defined');
is(ref $deuce, 'Bit::MorseSignals::Emitter', 'BME object is valid');
is(ref $deuce2, 'Bit::MorseSignals::Emitter', 'BME::new called as an object method works is valid');
ok(!defined Bit::MorseSignals::Emitter::new(), 'BME::new called without a class is invalid');
-eval { $deuce2 = new Bit::MorseSignals::Emitter qw/a b c/ };
+eval { $deuce2 = Bit::MorseSignals::Emitter->new(qw/a b c/) };
like($@, qr/Optional\s+arguments/, 'BME::new gets parameters as key => value pairs');
my $fake = { };
use Bit::MorseSignals::Emitter;
-my $deuce = new Bit::MorseSignals::Emitter;
+my $deuce = Bit::MorseSignals::Emitter->new;
sub test_msg {
my ($desc, $exp, $try_post) = @_;
use Bit::MorseSignals qw/BM_DATA_PLAIN/;
use Bit::MorseSignals::Emitter;
-my $deuce = new Bit::MorseSignals::Emitter utf8 => 'DO WANT';
+my $deuce = Bit::MorseSignals::Emitter->new(utf8 => 'DO WANT');
sub test_msg {
my ($desc, $exp) = @_;
use Bit::MorseSignals::Receiver;
-my $pants = new Bit::MorseSignals::Receiver;
+my $pants = Bit::MorseSignals::Receiver->new;
ok(defined $pants, 'BMR object is defined');
is(ref $pants, 'Bit::MorseSignals::Receiver', 'BMR object is valid');
is(ref $pants2, 'Bit::MorseSignals::Receiver', 'BMR::new called as an object method works is valid');
ok(!defined Bit::MorseSignals::Receiver::new(), 'BMR::new called without a class is invalid');
-eval { $pants2 = new Bit::MorseSignals::Receiver qw/a b c/ };
+eval { $pants2 = Bit::MorseSignals::Receiver->new(qw/a b c/) };
like($@, qr/Optional\s+arguments/, 'BME::new gets parameters as key => value pairs');
my $fake = { };
my $hlagh;
-my $pants = new Bit::MorseSignals::Receiver done => sub { $hlagh = $_[1] };
+my $pants = Bit::MorseSignals::Receiver->new(done => sub { $hlagh = $_[1] });
my $msg = 'x';
my @bits = split //, '111110' . '000' . '00011110' . '011111';
use Bit::MorseSignals::Receiver;
-my $pants = new Bit::MorseSignals::Receiver;
+my $pants = Bit::MorseSignals::Receiver->new;
my $msg = 'é';
my @bits = split //, '11110' . '100' . '11000011' . '10010101' . '01111';
my $hlagh;
-my $pants = new Bit::MorseSignals::Receiver done => sub { $hlagh = $_[1] };
+my $pants = Bit::MorseSignals::Receiver->new(done => sub { $hlagh = $_[1] });
my $wrong = "\x{FF}\x{FF}";
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 Bit::MorseSignals::Emitter;
-my $pants = new Bit::MorseSignals::Receiver done => sub {
+my $deuce = Bit::MorseSignals::Emitter->new;
+my $pants = Bit::MorseSignals::Receiver->new(done => sub {
my $cur = shift @msgs;
is($_[1], $cur, 'received message is correct');
-};
+});
$deuce->post($_) for @msgs;
$pants->push while defined ($_ = $deuce->pop); # ))<>((
sub cp { join '.', map ord, split //, $_[0] }
-my $deuce = new Bit::MorseSignals::Emitter;
-my $pants = new Bit::MorseSignals::Receiver done => sub {
+my $deuce = Bit::MorseSignals::Emitter->new;
+my $pants = Bit::MorseSignals::Receiver->new(done => sub {
my $cur = shift @msgs;
ok($_[1] eq $cur, 'got ' . cp($_[1]) . ', expected ' . cp($cur));
-};
+});
$deuce->post($_) for @msgs;
$pants->push while defined ($_ = $deuce->pop); # ))<>((
$msgs[7]->{wut} = { dong => [ 0 .. 99 ], recurse => $msgs[7] };
my $i = 0;
-my $deuce = new Bit::MorseSignals::Emitter;
-my $pants = new Bit::MorseSignals::Receiver done => sub {
+my $deuce = Bit::MorseSignals::Emitter->new;
+my $pants = Bit::MorseSignals::Receiver->new(done => sub {
my $cur = shift @msgs;
is_deeply($_[1], $cur, 'got object ' . $i++);
-};
+});
$deuce->post($_) for @msgs;
$pants->push while defined ($_ = $deuce->pop); # ))<>((