Commit | Line | Data |
33459055 |
1 | BEGIN { |
a9153838 |
2 | if( $ENV{PERL_CORE} ) { |
3 | chdir 't'; |
4 | @INC = ('../lib', 'lib'); |
5 | } |
6 | else { |
7 | unshift @INC, 't/lib'; |
8 | } |
33459055 |
9 | } |
10 | |
4dd974da |
11 | # Can't use Test.pm, that's a 5.005 thing. |
12 | package My::Test; |
13 | |
4dd974da |
14 | BEGIN { |
a9153838 |
15 | if( !$ENV{HARNESS_ACTIVE} && $ENV{PERL_CORE} ) { |
16 | print "1..0 # Skipped: Won't work with t/TEST\n"; |
17 | exit 0; |
18 | } |
19 | |
20 | # This feature requires a fairly new version of Test::Harness |
4dd974da |
21 | require Test::Harness; |
22 | if( $Test::Harness::VERSION < 1.20 ) { |
33459055 |
23 | print "1..0 # Skipped: Need Test::Harness 1.20 or up\n"; |
4dd974da |
24 | exit(0); |
25 | } |
26 | } |
27 | |
28 | print "1..2\n"; |
29 | |
30 | my $test_num = 1; |
31 | # Utility testing functions. |
32 | sub ok ($;$) { |
33 | my($test, $name) = @_; |
11ea77c5 |
34 | my $ok = ''; |
35 | $ok .= "not " unless $test; |
36 | $ok .= "ok $test_num"; |
37 | $ok .= " - $name" if defined $name; |
38 | $ok .= "\n"; |
39 | print $ok; |
4dd974da |
40 | $test_num++; |
41 | } |
42 | |
43 | |
44 | package main; |
45 | |
46 | require Test::Simple; |
47 | |
33459055 |
48 | require Test::Simple::Catch; |
49 | my($out, $err) = Test::Simple::Catch::caught(); |
4dd974da |
50 | |
51 | |
52 | Test::Simple->import('no_plan'); |
53 | |
54 | ok(1, 'foo'); |
55 | |
56 | |
57 | END { |
58 | My::Test::ok($$out eq <<OUT); |
59 | ok 1 - foo |
60 | 1..1 |
61 | OUT |
62 | |
63 | My::Test::ok($$err eq <<ERR); |
64 | ERR |
65 | |
66 | # Prevent Test::Simple from exiting with non zero |
67 | exit 0; |
68 | } |