Test::Simple/More/Builder/Tutorial 0.41
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / plan_is_noplan.t
1 BEGIN {
2     if( $ENV{PERL_CORE} ) {
3         chdir 't';
4         @INC = ('../lib', 'lib');
5     }
6     else {
7         unshift @INC, 't/lib';
8     }
9 }
10
11 # Can't use Test.pm, that's a 5.005 thing.
12 package My::Test;
13
14 BEGIN {
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
21     require Test::Harness;
22     if( $Test::Harness::VERSION < 1.20 ) {
23         print "1..0 # Skipped: Need Test::Harness 1.20 or up\n";
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) = @_;
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;
40     $test_num++;
41 }
42
43
44 package main;
45
46 require Test::Simple;
47
48 require Test::Simple::Catch;
49 my($out, $err) = Test::Simple::Catch::caught();
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 }