Assimilate Test-Simple 0.50
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / fail.t
CommitLineData
33459055 1#!perl -w
4dd974da 2
15db8fc4 3BEGIN {
a9153838 4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = ('../lib', 'lib');
7 }
8 else {
9 unshift @INC, 't/lib';
10 }
15db8fc4 11}
12
33459055 13use strict;
33459055 14
15require Test::Simple::Catch;
16my($out, $err) = Test::Simple::Catch::caught();
30e302f8 17local $ENV{HARNESS_ACTIVE} = 0;
33459055 18
19
4dd974da 20# Can't use Test.pm, that's a 5.005 thing.
21package My::Test;
22
23print "1..2\n";
24
25my $test_num = 1;
26# Utility testing functions.
27sub ok ($;$) {
28 my($test, $name) = @_;
11ea77c5 29 my $ok = '';
30 $ok .= "not " unless $test;
31 $ok .= "ok $test_num";
32 $ok .= " - $name" if defined $name;
33 $ok .= "\n";
34 print $ok;
4dd974da 35 $test_num++;
36}
37
38
39package main;
40
41require Test::Simple;
4dd974da 42Test::Simple->import(tests => 5);
43
33459055 44#line 35
4dd974da 45ok( 1, 'passing' );
46ok( 2, 'passing still' );
47ok( 3, 'still passing' );
48ok( 0, 'oh no!' );
49ok( 0, 'damnit' );
50
51
52END {
53 My::Test::ok($$out eq <<OUT);
541..5
55ok 1 - passing
56ok 2 - passing still
57ok 3 - still passing
58not ok 4 - oh no!
59not ok 5 - damnit
60OUT
61
33459055 62 My::Test::ok($$err eq <<ERR);
63# Failed test ($0 at line 38)
64# Failed test ($0 at line 39)
65# Looks like you failed 2 tests of 5.
66ERR
4dd974da 67
68 # Prevent Test::Simple from exiting with non zero
69 exit 0;
70}