Test::Simple/More/Builder/Tutorial 0.41
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / plan_is_noplan.t
CommitLineData
33459055 1BEGIN {
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.
12package My::Test;
13
4dd974da 14BEGIN {
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
28print "1..2\n";
29
30my $test_num = 1;
31# Utility testing functions.
32sub 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
44package main;
45
46require Test::Simple;
47
33459055 48require Test::Simple::Catch;
49my($out, $err) = Test::Simple::Catch::caught();
4dd974da 50
51
52Test::Simple->import('no_plan');
53
54ok(1, 'foo');
55
56
57END {
58 My::Test::ok($$out eq <<OUT);
59ok 1 - foo
601..1
61OUT
62
63 My::Test::ok($$err eq <<ERR);
64ERR
65
66 # Prevent Test::Simple from exiting with non zero
67 exit 0;
68}