PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB` REDROOM
PHP 5.6.40
Preview: finally.t Size: 2.50 KB
//usr/share/doc/perl-Try-Tiny/t/finally.t

use strict;
use warnings;

use Test::More tests => 30;
use Try::Tiny;

try {
  my $a = 1+1;
} catch {
  fail('Cannot go into catch block because we did not throw an exception')
} finally {
  pass('Moved into finally from try');
};

try {
  die('Die');
} catch {
  ok($_ =~ /Die/, 'Error text as expected');
  pass('Into catch block as we died in try');
} finally {
  pass('Moved into finally from catch');
};

try {
  die('Die');
} finally {
  pass('Moved into finally from catch');
} catch {
  ok($_ =~ /Die/, 'Error text as expected');
};

try {
  die('Die');
} finally {
  pass('Moved into finally block when try throws an exception and we have no catch block');
};

try {
  die('Die');
} finally {
  pass('First finally clause run');
} finally {
  pass('Second finally clause run');
};

try {
  # do not die
} finally {
  if (@_) {
    fail("errors reported: @_");
  } else {
    pass("no error reported") ;
  }
};

try {
  die("Die\n");
} finally {
  is_deeply(\@_, [ "Die\n" ], "finally got passed the exception");
};

try {
  try {
    die "foo";
  }
  catch {
    die "bar";
  }
  finally {
    pass("finally called");
  };
};

$_ = "foo";
try {
  is($_, "foo", "not localized in try");
}
catch {
}
finally {
  is(scalar(@_), 0, "nothing in \@_ (finally)");
  is($_, "foo", "\$_ not localized (finally)");
};
is($_, "foo", "same afterwards");

$_ = "foo";
try {
  is($_, "foo", "not localized in try");
  die "bar\n";
}
catch {
  is($_[0], "bar\n", "error in \@_ (catch)");
  is($_, "bar\n", "error in \$_ (catch)");
}
finally {
  is(scalar(@_), 1, "error in \@_ (finally)");
  is($_[0], "bar\n", "error in \@_ (finally)");
  is($_, "foo", "\$_ not localized (finally)");
};
is($_, "foo", "same afterwards");

{
  my @warnings;
  local $SIG{__WARN__} = sub {
    $_[0] =~ /\QExecution of finally() block CODE(0x\E.+\Q) resulted in an exception/
      ? push @warnings, @_
      : warn @_
  };

  try {
    die 'tring'
  } finally {
    die 'fin 1'
  } finally {
    pass('fin 2 called')
  } finally {
    die 'fin 3'
  };

  is( scalar @warnings, 2, 'warnings from both fatal finally blocks' );

  my @originals = sort map { $_ =~ /Original exception text follows:\n\n(.+)/s } @warnings;

  like $originals[0], qr/fin 1 at/, 'First warning contains original exception';
  like $originals[1], qr/fin 3 at/, 'Second warning contains original exception';
}

{
  my $finally;
  SKIP: {
    try {
      pass('before skip in try');
      skip 'whee', 1;
      fail('not reached');
    } finally {
      $finally = 1;
    };
  }
  ok $finally, 'finally ran';
}

Directory Contents

Dirs: 1 × Files: 12

Name Size Perms Modified Actions
lib DIR
- drwxr-xr-x 2025-04-06 18:14:09
Edit Download
10.07 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download
5.83 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download
3.00 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download
1.17 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download
1.50 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download
2.50 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download
694 B lrw-r--r-- 2017-12-21 07:23:09
Edit Download
953 B lrw-r--r-- 2017-12-21 07:23:09
Edit Download
550 B lrw-r--r-- 2017-12-21 07:23:09
Edit Download
685 B lrw-r--r-- 2017-12-21 07:23:09
Edit Download
669 B lrw-r--r-- 2017-12-21 07:23:09
Edit Download
1.06 KB lrw-r--r-- 2017-12-21 07:23:09
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 REDROOM — Secure File Manager. All rights reserved. Built with ❤️ & Red Dark UI