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