summaryrefslogtreecommitdiff
path: root/t/12wrong-error-var.t
blob: 888c723729408654ed123cf7574800fb660e9ca2 (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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 2;

use Error qw(:try);

try {
  eval {
   throw Error::Simple "This is caught by eval, not by try.";
  };

  # TEST
  ok (($@ && $@ =~ /This is caught by eval, not by try/),
      "Checking that eval { ... } is sane"
     );

  print "# Error::THROWN = $Error::THROWN\n";

  die "This is a simple 'die' exception.";

  # not reached
}
otherwise {
  my $E = shift;
  my $t = $Error::THROWN ? "$Error::THROWN" : '';
  print "# Error::THROWN = $t\n";
  $E ||= '';
  print "# E = $E\n";

  # TEST
  ok ("$E" =~ /This is a simple 'die' exception/,
      "Checking that the argument to otherwise is the thrown exception"
  );
};