#!perl -w BEGIN { if( $ENV{PERL_CORE} ) { chdir 't'; @INC = ('../lib', 'lib'); } else { unshift @INC, 't/lib'; } } use strict; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); local $ENV{HARNESS_ACTIVE} = 0; # Can't use Test.pm, that's a 5.005 thing. package My::Test; # This has to be a require or else the END block below runs before # Test::Builder's own and the ending diagnostics don't come out right. require Test::Builder; my $TB = Test::Builder->create; $TB->plan(tests => 23); sub like ($$;$) { $TB->like(@_); } sub is ($$;$) { $TB->is_eq(@_); } sub main::err_ok ($) { my($expect) = @_; my $got = $err->read; return $TB->is_eq( $got, $expect ); } sub main::err_like ($) { my($expect) = @_; my $got = $err->read; return $TB->like( $got, qr/$expect/ ); } package main; require Test::More; my $Total = 36; Test::More->import(tests => $Total); # This should all work in the presence of a __DIE__ handler. local $SIG{__DIE__} = sub { $TB->ok(0, "DIE handler called: ".join "", @_); }; my $tb = Test::More->builder; $tb->use_numbers(0); my $Filename = quotemeta $0; # Preserve the line numbers. #line 38 ok( 0, 'failing' ); err_ok( <can(...)' # at $0 line 52. # Mooble::Hooble::Yooble->can('this') failed # Mooble::Hooble::Yooble->can('that') failed # Failed test 'Mooble::Hooble::Yooble->can(...)' # at $0 line 53. # can_ok() called with no methods # Failed test '->can(...)' # at $0 line 54. # can_ok() called with empty class or reference # Failed test 'ARRAY->can('foo')' # at $0 line 55. # ARRAY->can('foo') failed ERR #line 55 isa_ok(bless([], "Foo"), "Wibble"); isa_ok(42, "Wibble", "My Wibble"); isa_ok(undef, "Wibble", "Another Wibble"); isa_ok([], "HASH"); err_ok( <read, "/^$more_err_re/"); #line 85 require_ok('ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble'); $more_err_re = <read, "/^$more_err_re/"); #line 88 END { $TB->is_eq($$out, <can(...) not ok - Mooble::Hooble::Yooble->can(...) not ok - ->can(...) not ok - ARRAY->can('foo') not ok - The object isa Wibble not ok - My Wibble isa Wibble not ok - Another Wibble isa Wibble not ok - The object isa HASH not ok - new() died not ok - new() died not ok - The object isa Foo not ok - The object isa Bar not ok - The object isa Baz not ok - no args isa Baz not ok - cmp_ok eq not ok - == not ok - != not ok - && not ok - eq with numbers not ok - == with strings not ok - eq with stringified errno not ok - eq with numerified errno not ok - use Hooble::mooble::yooble; not ok - require ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble; OUT err_ok( <