Developer-Dashboard
view release on metacpan or search on metacpan
t/233-goroutine-shared-object-coverage.t view on Meta::CPAN
wait_all();
ok( $saw_cancel, 'running routine observes the cooperative cancel flag' );
is( $co_op->status, 'killed', 'cooperatively cancelled routine reports killed' );
ok( $co_op->is_killed, 'cooperatively cancelled routine is marked as killed' );
is( $killer->status, 'done', 'killer routine finishes normally' );
# -------------------------------------------------------------------------
# Timeout validation
# -------------------------------------------------------------------------
for my $bad_timeout ( undef, [], 'not-a-number', 'NaN', 'Inf', '1e999', -1 ) {
my $routine = bless {}, 'Developer::Dashboard::GoRoutine::Routine';
my $ok = eval { $routine->timeout($bad_timeout); 1 };
ok( !$ok, 'invalid timeout is rejected' );
like( $@, qr/timeout\(\) requires a non-negative number/, 'invalid timeout has a clear diagnostic' );
}
{
package Local::NaNTimeout;
use overload
'""' => sub { return '1' },
'0+' => sub { return POSIX::nan() },
fallback => 1;
package main;
my $routine = bless {}, 'Developer::Dashboard::GoRoutine::Routine';
my $nan_timeout = bless {}, 'Local::NaNTimeout';
my $ok = eval { $routine->timeout($nan_timeout); 1 };
ok( !$ok, 'timeout rejects a value that stringifies numerically but numifies to NaN' );
like( $@, qr/timeout\(\) requires a non-negative number/,
'NaN timeout rejection uses the public validation diagnostic' );
}
# -------------------------------------------------------------------------
# _share_many and share on pre-tied variables
# -------------------------------------------------------------------------
{
my $scalar_value = 21;
my @array_values = qw(alpha beta);
my %hash_values = ( key => 'value' );
t/233-goroutine-shared-object-coverage.t view on Meta::CPAN
t/233-goroutine-shared-object-coverage.t - exercise GoRoutine shared values as plain Perl values
=head1 PURPOSE
This test exercises shared scalars, hashes, arrays, scalar references,
blessed values, regexps, code references, filehandles, and formats under the
single-threaded GoRoutine engine, where C<share> is a no-op and every shared
value is just a plain Perl value in the one interpreter. It also covers the
channel and routine-handle public API with real routines: pending/killed/
timed-out/exited/done statuses, cooperative cancellation, timeout validation
(including a NaN overload), and the C<_share_many> helper. Routines observe
the same shared values the main program sees, and channel values pass by
reference.
=head1 WHY IT EXISTS
The old version of this file covered the tied-proxy marshalling layer that
adapted native shared nodes to ordinary Perl references. That layer is gone
with the perl_clone engine, so the file now pins the new contract instead:
plain values, final observable values, and the public routine/channel API.
The separate integration tests exercise real routine scheduling outside
( run in 1.529 second using v1.01-cache-2.11-cpan-60884a8df76 )