File: 12wrong-error-var.t

package info (click to toggle)
liberror-perl 0.17-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 196 kB
  • ctags: 63
  • sloc: perl: 1,056; makefile: 38
file content (37 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (7)
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"
  );
};