Move Test::Simple from lib to ext.
[p5sagit/p5-mst-13.2.git] / ext / Test-Simple / t / fail.t
CommitLineData
33459055 1#!perl -w
3e887aae 2
3# Simple test of what failure output looks like
4dd974da 4
15db8fc4 5BEGIN {
a9153838 6 if( $ENV{PERL_CORE} ) {
7 chdir 't';
8 @INC = ('../lib', 'lib');
9 }
10 else {
11 unshift @INC, 't/lib';
12 }
15db8fc4 13}
14
33459055 15use strict;
33459055 16
3e887aae 17# Normalize the output whether we're running under Test::Harness or not.
30e302f8 18local $ENV{HARNESS_ACTIVE} = 0;
33459055 19
3e887aae 20use Test::Builder;
21use Test::Builder::NoOutput;
33459055 22
3e887aae 23my $Test = Test::Builder->new;
4dd974da 24
3e887aae 25# Set up a builder to record some failing tests.
26{
27 my $tb = Test::Builder::NoOutput->create;
28 $tb->plan( tests => 5 );
4dd974da 29
3e887aae 30#line 28
31 $tb->ok( 1, 'passing' );
32 $tb->ok( 2, 'passing still' );
33 $tb->ok( 3, 'still passing' );
34 $tb->ok( 0, 'oh no!' );
35 $tb->ok( 0, 'damnit' );
36 $tb->_ending;
4dd974da 37
3e887aae 38 $Test->is_eq($tb->read('out'), <<OUT);
4dd974da 391..5
40ok 1 - passing
41ok 2 - passing still
42ok 3 - still passing
43not ok 4 - oh no!
44not ok 5 - damnit
45OUT
46
3e887aae 47 $Test->is_eq($tb->read('err'), <<ERR);
b1ddf169 48# Failed test 'oh no!'
3e887aae 49# at $0 line 31.
b1ddf169 50# Failed test 'damnit'
3e887aae 51# at $0 line 32.
33459055 52# Looks like you failed 2 tests of 5.
53ERR
4dd974da 54
3e887aae 55 $Test->done_testing(2);
4dd974da 56}