Move Test::Simple from lib to ext.
[p5sagit/p5-mst-13.2.git] / ext / Test-Simple / t / Builder / carp.t
CommitLineData
004caa16 1#!/usr/bin/perl
2
3BEGIN {
4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = '../lib';
7 }
8}
9
10
11use Test::More tests => 3;
12use Test::Builder;
13
14my $tb = Test::Builder->create;
15sub foo { $tb->croak("foo") }
16sub bar { $tb->carp("bar") }
17
18eval { foo() };
19is $@, sprintf "foo at %s line %s.\n", $0, __LINE__ - 1;
20
21eval { $tb->croak("this") };
22is $@, 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}