+# goto
+
+SKIP: {
+ skip "goto to an uplevel'd stack frame does not work on perl 5\.6"
+ => 2 if "$]" < 5.008;
+
+ {
+ my $desc = 'values returned from goto';
+ local $@;
+ my $cb = sub { 'hello' };
+ my @ret = eval {
+ 'a', sub {
+ 'b', sub {
+ 'c', &uplevel(sub {
+ 'd', (goto $cb), 'w'
+ } => UP), 'x'
+ }->(), 'y'
+ }->(), 'z'
+ };
+ is $@, '', "$desc: did not croak";
+ is_deeply \@ret, [ qw<a b c hello x y z> ], "$desc: returned values";
+ }
+}
+
+# uplevel() to uplevel()
+
+{
+ my $desc = '\&uplevel as the uplevel() callback';
+ local $@;
+ eval {
+ my @ret = sub {
+ my $cxt = HERE;
+ my @ret = sub {
+ my @ret = sub {
+ # Note that an XS call does not need a context, so after the first uplevel
+ # call UP will point to the scope above the first target.
+ 'a', uplevel(\&uplevel => (sub {
+ return qw<x y z>;
+ } => UP) => UP), 'b';
+ }->();
+ is "@ret", 'a x y z b', "$desc: returned from uplevel";
+ return qw<u v w>;
+ }->();
+ is "@ret", 'u v w', "$desc: returned from the first target";
+ return qw<m n>;
+ }->();
+ is "@ret", 'm n', "$desc: returned from the second target";
+ };
+ is $@, '', "$desc: no error";
+}
+