File: 03_die.t

package info (click to toggle)
libguard-perl 1.022-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 104 kB
  • ctags: 1
  • sloc: perl: 12; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (5)
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
43
44
45
46
47
48
49
50
51
52
53
54
BEGIN { $| = 1; print "1..11\n"; }

use Guard;

print "ok 1\n";

$Guard::DIED = sub {
   print $@ =~ /^x1 at / ? "" : "not ", "ok 3 # $@\n";
};

eval {
   scope_guard { die "x1" };
   print "ok 2\n";
};

print $@ ? "not " : "", "ok 4 # $@\n";

$Guard::DIED = sub {
   print $@ =~ /^x2 at / ? "" : "not ", "ok 6 # $@\n";
};

eval {
   scope_guard { die "x2" };
   print "ok 5\n";
   die "x3";
};

print $@ =~ /^x3 at /s ? "" : "not ", "ok 7 # $@\n";

our $x4 = 1;

$SIG{__DIE__} = sub {
   if ($x4) {
      print "not ok 9\n";
   } else {
      print $_[0] =~ /^x5 at / ? "" : "not ", "ok 11 # $_[0]\n";
   }
   exit 0;
};

{
   $Guard::DIED = sub {
      print $@ =~ /^x4 at / ? "" : "not ", "ok 9 # $@\n";
   };

   scope_guard { die "x4" };
   print "ok 8\n";
};

$x4 = 0;
print "ok 10\n";

die "x5";