Commit | Line | Data |
004caa16 |
1 | #!/usr/bin/perl |
3c4bf434 |
2 | # $Id$ |
004caa16 |
3 | |
4 | BEGIN { |
5 | if( $ENV{PERL_CORE} ) { |
6 | chdir 't'; |
7 | @INC = '../lib'; |
8 | } |
9 | } |
10 | |
11 | |
12 | use Test::More tests => 3; |
13 | use Test::Builder; |
14 | |
15 | my $tb = Test::Builder->create; |
16 | sub foo { $tb->croak("foo") } |
17 | sub bar { $tb->carp("bar") } |
18 | |
19 | eval { foo() }; |
20 | is $@, sprintf "foo at %s line %s.\n", $0, __LINE__ - 1; |
21 | |
22 | eval { $tb->croak("this") }; |
23 | is $@, sprintf "this at %s line %s.\n", $0, __LINE__ - 1; |
24 | |
25 | { |
26 | my $warning = ''; |
27 | local $SIG{__WARN__} = sub { |
28 | $warning .= join '', @_; |
29 | }; |
30 | |
31 | bar(); |
32 | is $warning, sprintf "bar at %s line %s.\n", $0, __LINE__ - 1; |
33 | } |