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 local $ENV{HARNESS_IS_VERBOSE} = 0; 51 52#line 62 53 fail( "this fails" ); 54 err_ok( <<ERR ); 55# Failed test 'this fails' 56# at $0 line 62. 57ERR 58 59#line 72 60 is( 1, 0 ); 61 err_ok( <<ERR ); 62# Failed test at $0 line 72. 63# got: '1' 64# expected: '0' 65ERR 66} 67 68{ 69 local $ENV{HARNESS_ACTIVE} = 1; 70 local $ENV{HARNESS_IS_VERBOSE} = 0; 71 72#line 71 73 fail( "this fails" ); 74 err_ok( <<ERR ); 75 76# Failed test 'this fails' 77# at $0 line 71. 78ERR 79 80 81#line 84 82 is( 1, 0 ); 83 err_ok( <<ERR ); 84 85# Failed test at $0 line 84. 86# got: '1' 87# expected: '0' 88ERR 89 90} 91