Scope::Upper 0.21 is required.
$file = "lib/$file.pm";
my %PREREQ_PM = (
- 'Scope::Upper' => '0.18',
+ 'Scope::Upper' => '0.21',
'Scalar::Util' => 0,
);
use Carp ();
use Scalar::Util ();
-use Scope::Upper 0.18 ();
+use Scope::Upper 0.21 ();
=head1 NAME
Scope::Upper::unwind(@_ => $self->cxt);
}
+=head2 C<yield>
+
+ $cxt->yield(@values);
+
+Immediately returns the scalars listed in C<@values> from the topic context, whatever it may be (except a substitution eval context).
+
+See L<Scope::Upper/yield> for details.
+
+=cut
+
+sub yield {
+ my $self = shift;
+
+ $self->assert_valid;
+
+ Scope::Upper::yield(@_ => $self->cxt);
+}
+
=head2 C<uplevel>
my @ret = $cxt->uplevel($code, @args);
L<Carp> (core module since perl 5), L<Scalar::Util> (since 5.7.3).
-L<Scope::Upper> 0.18.
+L<Scope::Upper> 0.21.
=head1 SEE ALSO
uid is_valid assert_valid
want
up sub eval
- reap localize localize_elem localize_delete unwind uplevel
+ reap localize localize_elem localize_delete
+ unwind yield
+ uplevel
>;
plan tests => scalar(@methods);
use strict;
use warnings;
-use Test::More tests => 4 * 3 + 2;
+use Test::More tests => 4 * 3 + 3;
use Scope::Context;
is_deeply \@res, [ 1, 2, 3 ], 'unwind: done';
}
+{
+ my @res = do {
+ sub {
+ my $up = Scope::Context->up;
+ $up->yield(4, 5, 6);
+ fail 'yield: not reached 1';
+ }->();
+ fail 'yield: not reached 2';
+ return qw<x y z t>;
+ };
+ is_deeply \@res, [ 4, 5, 6 ], 'yield: done';
+}
+
{
sub outer {
inner(@_);
use strict;
use warnings;
-use Test::More tests => 4 + 9;
+use Test::More tests => 4 + 10;
use Scope::Context;
my @methods = qw<
up sub eval
- reap localize localize_elem localize_delete unwind uplevel
+ reap localize localize_elem localize_delete
+ unwind yield
+ uplevel
>;
for my $action (@methods) {
local $@;