1#!perl -w 2 3BEGIN { 4 if( $ENV{PERL_CORE} ) { 5 chdir 't'; 6 @INC = '../lib'; 7 } 8} 9 10# Can't use Test.pm, that's a 5.005 thing. 11package My::Test; 12 13print "1..2\n"; 14 15my $test_num = 1; 16# Utility testing functions. 17sub ok ($;$) { 18 my($test, $name) = @_; 19 my $ok = ''; 20 $ok .= "not " unless $test; 21 $ok .= "ok $test_num"; 22 $ok .= " - $name" if defined $name; 23 $ok .= "\n"; 24 print $ok; 25 $test_num++; 26} 27 28 29package main; 30 31require Test::Simple; 32 33chdir 't'; 34push @INC, '../t/lib/'; 35require Test::Simple::Catch; 36my($out, $err) = Test::Simple::Catch::caught(); 37 38Test::Simple->import(tests => 3); 39 40#line 30 41ok(1, 'Foo'); 42ok(0, 'Bar'); 43ok(1, 'Yar'); 44ok(1, 'Car'); 45ok(0, 'Sar'); 46 47END { 48 My::Test::ok($$out eq <<OUT); 491..3 50ok 1 - Foo 51not ok 2 - Bar 52ok 3 - Yar 53ok 4 - Car 54not ok 5 - Sar 55OUT 56 57 My::Test::ok($$err eq <<ERR); 58# Failed test ($0 at line 31) 59# Failed test ($0 at line 34) 60# Looks like you planned 3 tests but ran 2 extra. 61ERR 62 63 exit 0; 64} 65