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 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); 27 28# Utility testing functions. 29sub ok ($;$) { 30 return $TB->ok(@_); 31} 32 33 34sub main::err_ok ($) { 35 my($expect) = @_; 36 my $got = $err->read; 37 38 return $TB->is_eq( $got, $expect ); 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" ); 53 err_ok( <<ERR ); 54# Failed test 'this fails' 55# at $0 line 62. 56ERR 57 58#line 72 59 is( 1, 0 ); 60 err_ok( <<ERR ); 61# Failed test at $0 line 72. 62# got: '1' 63# expected: '0' 64ERR 65} 66 67{ 68 local $ENV{HARNESS_ACTIVE} = 1; 69 70#line 71 71 fail( "this fails" ); 72 err_ok( <<ERR ); 73 74# Failed test 'this fails' 75# at $0 line 71. 76ERR 77 78 79#line 84 80 is( 1, 0 ); 81 err_ok( <<ERR ); 82 83# Failed test at $0 line 84. 84# got: '1' 85# expected: '0' 86ERR 87 88} 89