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 15require Test::Simple::Catch; 16my($out, $err) = Test::Simple::Catch::caught(); 17local $ENV{HARNESS_ACTIVE} = 0; 18 19 20# Can't use Test.pm, that's a 5.005 thing. 21package My::Test; 22 23print "1..2\n"; 24 25my $test_num = 1; 26# Utility testing functions. 27sub ok ($;$) { 28 my($test, $name) = @_; 29 my $ok = ''; 30 $ok .= "not " unless $test; 31 $ok .= "ok $test_num"; 32 $ok .= " - $name" if defined $name; 33 $ok .= "\n"; 34 print $ok; 35 $test_num++; 36} 37 38 39package main; 40 41require Test::Simple; 42Test::Simple->import(tests => 5); 43 44#line 35 45ok( 1, 'passing' ); 46ok( 2, 'passing still' ); 47ok( 3, 'still passing' ); 48ok( 0, 'oh no!' ); 49ok( 0, 'damnit' ); 50 51 52END { 53 My::Test::ok($$out eq <<OUT); 541..5 55ok 1 - passing 56ok 2 - passing still 57ok 3 - still passing 58not ok 4 - oh no! 59not ok 5 - damnit 60OUT 61 62 My::Test::ok($$err eq <<ERR); 63# Failed test 'oh no!' 64# in $0 at line 38. 65# Failed test 'damnit' 66# in $0 at line 39. 67# Looks like you failed 2 tests of 5. 68ERR 69 70 # Prevent Test::Simple from exiting with non zero 71 exit 0; 72} 73