Remove broken links for hip communications inc.
[p5sagit/p5-mst-13.2.git] / ext / Test-Simple / t / Builder / try.t
1 #!perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = ('../lib', 'lib');
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12
13 use strict;
14
15 use Test::More 'no_plan';
16
17 require Test::Builder;
18 my $tb = Test::Builder->new;
19
20
21 # Test that _try() has no effect on $@ and $! and is not effected by
22 # __DIE__
23 {
24     local $SIG{__DIE__} = sub { fail("DIE handler called: @_") };
25     local $@ = 42;
26     local $! = 23;
27
28     is $tb->_try(sub { 2 }), 2;
29     is $tb->_try(sub { return '' }), '';
30
31     is $tb->_try(sub { die; }), undef;
32
33     is_deeply [$tb->_try(sub { die "Foo\n" })], [undef, "Foo\n"];
34
35     is $@, 42;
36     cmp_ok $!, '==', 23;
37 }
38
39 ok !eval {
40     $tb->_try(sub { die "Died\n" }, die_on_fail => 1);
41 };
42 is $@, "Died\n";