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