summaryrefslogtreecommitdiff
path: root/t/07try-in-obj-destructor.t
blob: b15bff2c8823a79d3403c1357ea02b80c504e839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl -w

use strict;

use Test::More tests => 1;

use Error qw/ :try /;

package ErrorTest;
use Error qw/ :try /;

sub new {
  return bless {}, 'ErrorTest';
}

sub DESTROY {
  my $self = shift;
  try { 1; } otherwise { };
  return;
}

package main;

my $E;
try {

  my $y = ErrorTest->new();
#  throw Error::Simple("Object die");
  die "throw normal die";

} catch Error with {
  $E = shift;
} otherwise {
  $E = shift;
};

# TEST
is ($E->{'-text'}, "throw normal die",
    "Testing that the excpetion is not trampeled"
);