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