Upgrade to Test-Simple-0.82.
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / harness_active.t
CommitLineData
30e302f8 1#!perl -w
ccbd73a4 2# $Id: /mirror/googlecode/test-more/t/harness_active.t 57943 2008-08-18T02:09:22.275428Z brooklyn.kid51 $
30e302f8 3
4BEGIN {
5 if( $ENV{PERL_CORE} ) {
6 chdir 't';
7 @INC = ('../lib', 'lib');
8 }
9 else {
10 unshift @INC, 't/lib';
11 }
12}
13
14use strict;
15
16use Test::Simple::Catch;
17my($out, $err) = Test::Simple::Catch::caught();
18
19
20# Can't use Test.pm, that's a 5.005 thing.
21package My::Test;
22
b1ddf169 23# This has to be a require or else the END block below runs before
24# Test::Builder's own and the ending diagnostics don't come out right.
25require Test::Builder;
26my $TB = Test::Builder->create;
27$TB->plan(tests => 4);
30e302f8 28
30e302f8 29# Utility testing functions.
30sub ok ($;$) {
b1ddf169 31 return $TB->ok(@_);
30e302f8 32}
33
34
0257f296 35sub main::err_ok ($) {
30e302f8 36 my($expect) = @_;
37 my $got = $err->read;
38
b1ddf169 39 return $TB->is_eq( $got, $expect );
30e302f8 40}
41
42
43package main;
44
45require Test::More;
46Test::More->import(tests => 4);
47Test::More->builder->no_ending(1);
48
49{
50 local $ENV{HARNESS_ACTIVE} = 0;
51
52#line 62
53 fail( "this fails" );
0257f296 54 err_ok( <<ERR );
b1ddf169 55# Failed test 'this fails'
b7f9bbeb 56# at $0 line 62.
30e302f8 57ERR
58
59#line 72
60 is( 1, 0 );
0257f296 61 err_ok( <<ERR );
b7f9bbeb 62# Failed test at $0 line 72.
30e302f8 63# got: '1'
64# expected: '0'
65ERR
66}
67
68{
69 local $ENV{HARNESS_ACTIVE} = 1;
70
71#line 71
72 fail( "this fails" );
0257f296 73 err_ok( <<ERR );
30e302f8 74
b1ddf169 75# Failed test 'this fails'
b7f9bbeb 76# at $0 line 71.
30e302f8 77ERR
78
79
80#line 84
81 is( 1, 0 );
0257f296 82 err_ok( <<ERR );
30e302f8 83
b7f9bbeb 84# Failed test at $0 line 84.
30e302f8 85# got: '1'
86# expected: '0'
87ERR
88
89}