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