1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
use Test::More;
# Non-blocking tests (dequeue_nb and recv_nb) were disabled
# in MCE 1.884 for the Windows platform; copied here in xt.
# The following tests pass on Windows, typically.
BEGIN {
use_ok 'MCE::Flow';
use_ok 'MCE::Queue';
}
MCE::Flow->init(
max_workers => 1
);
# https://sacred-texts.com/cla/usappho/sph02.htm (VI)
my $sappho_text =
"καὶ γάρ αἰ φεύγει, ταχέωσ διώξει,
αἰ δὲ δῶρα μὴ δέκετ ἀλλά δώσει,
αἰ δὲ μὴ φίλει ταχέωσ φιλήσει,
κωὐκ ἐθέλοισα." . "Ǣ";
my $translation =
"For if now she flees, quickly she shall follow
And if she spurns gifts, soon shall she offer them
Yea, if she knows not love, soon shall she feel it
Even reluctant.";
sub check_unicode_out {
my ($description, $value) = @_;
is( $value, $sappho_text, $description );
}
# MCE::Queue provides 2 operating modes (manager and worker).
# This will test (normal queue) by the manager process.
my @a = ();
my $q = MCE::Queue->new( queue => \@a );
$q->enqueue($sappho_text);
is( $q->dequeue_nb, $sappho_text, 'check dequeue_nb - manager' );
# This will test (normal queue) by the MCE worker process.
mce_flow sub {
$q->enqueue($sappho_text);
MCE->do('check_unicode_out', 'check dequeue_nb - worker', $q->dequeue_nb);
return;
};
MCE::Flow->finish;
done_testing;
|