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