summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
c983cb7)
Scope::Upper 0.21 is required.
$file = "lib/$file.pm";
my %PREREQ_PM = (
$file = "lib/$file.pm";
my %PREREQ_PM = (
- 'Scope::Upper' => '0.18',
+ 'Scope::Upper' => '0.21',
use Carp ();
use Scalar::Util ();
use Carp ();
use Scalar::Util ();
-use Scope::Upper 0.18 ();
+use Scope::Upper 0.21 ();
Scope::Upper::unwind(@_ => $self->cxt);
}
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);
=head2 C<uplevel>
my @ret = $cxt->uplevel($code, @args);
L<Carp> (core module since perl 5), L<Scalar::Util> (since 5.7.3).
L<Carp> (core module since perl 5), L<Scalar::Util> (since 5.7.3).
uid is_valid assert_valid
want
up sub eval
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);
>;
plan tests => scalar(@methods);
use strict;
use warnings;
use strict;
use warnings;
-use Test::More tests => 4 * 3 + 2;
+use Test::More tests => 4 * 3 + 3;
is_deeply \@res, [ 1, 2, 3 ], 'unwind: done';
}
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';
+}
+
use strict;
use warnings;
use strict;
use warnings;
-use Test::More tests => 4 + 9;
+use Test::More tests => 4 + 10;
my @methods = qw<
up sub eval
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 $@;
>;
for my $action (@methods) {
local $@;