8 use Test::More 'no_plan';
10 use Bit::MorseSignals qw/BM_DATA_PLAIN/;
11 use Bit::MorseSignals::Emitter;
13 my $deuce = new Bit::MorseSignals::Emitter utf8 => 'DO WANT';
16 my ($desc, $exp) = @_;
22 ok($deuce->busy, "$desc: BME object is busy after pop $i");
23 is($b, $_, "$desc: bit $i is correct");
27 ok(!$deuce->busy, "$desc: BME object is no longer busy when over");
28 is($b, $last, "$desc: last bit is correct");
32 my @exp = split //, '11110' . '100' . '11000011' . '10010101' . '01111';
34 my $ret = eval { $deuce->post($msg) };
35 ok(!$@, "simple post doesn't croak ($@)");
36 ok(defined $ret && $ret > 0, 'simple post was successful');
37 ok($deuce->busy, 'BME object is busy after simple post');
38 ok(!$deuce->queued, 'BME object has no message queued after simple post');
40 test_msg 'simple post', [ @exp ];
41 ok(!defined $deuce->pop, "simple post: message is over");
43 $ret = eval { $deuce->post($msg) };
44 ok(!$@, "first double post doesn't croak ($@)");
45 ok(defined $ret && $ret > 0, 'first double post was successful');
46 ok($deuce->busy, 'BME object is busy after first double post');
47 ok(!$deuce->queued, 'BME object has no message queued after first double post');
49 $ret = eval { $deuce->post($msg) };
50 ok(!$@, "second double post doesn't croak ($@)");
51 ok(defined $ret && $ret < 0, 'second double post was queued');
52 ok($deuce->busy, 'BME object is busy after second double post');
53 ok($deuce->queued, 'BME object has a message queued after second double post');
55 test_msg 'first double post', [ @exp ];
56 ok(!$deuce->busy && $deuce->queued, 'first double post: BME object is no longer busy but still has something in queue between the two posts');
57 test_msg 'second double post', [ @exp ];
58 ok(!defined $deuce->pop, "second double post: message is over");
61 @exp = split //, '00001' . '000' . '10010111' . '10000';
63 $ret = eval { $deuce->post($msg, type => BM_DATA_PLAIN); };
64 ok(!$@, "forced non-utf8 post doesn't croak ($@)");
65 ok(defined $ret && $ret > 0, 'forced non-utf8 post was successful');
66 ok($deuce->busy, 'BME object is busy after forced non-utf8 post');
67 ok(!$deuce->queued, 'BME object has no message queued after forced non-utf8 post');
69 test_msg 'forced non-utf8 post', [ @exp ];
70 ok(!defined $deuce->pop, "forced non-utf8 post: message is over");