[PATCH] Syncing with Test::Simple 0.19
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / fail.t
CommitLineData
4dd974da 1use strict;
2
15db8fc4 3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
4dd974da 8# Can't use Test.pm, that's a 5.005 thing.
9package My::Test;
10
11print "1..2\n";
12
13my $test_num = 1;
14# Utility testing functions.
15sub ok ($;$) {
16 my($test, $name) = @_;
11ea77c5 17 my $ok = '';
18 $ok .= "not " unless $test;
19 $ok .= "ok $test_num";
20 $ok .= " - $name" if defined $name;
21 $ok .= "\n";
22 print $ok;
4dd974da 23 $test_num++;
24}
25
26
27package main;
28
29require Test::Simple;
30
15db8fc4 31push @INC, '../t/lib';
d020a79a 32require Test::Simple::Catch;
33my($out, $err) = Test::Simple::Catch::caught();
4dd974da 34
35Test::Simple->import(tests => 5);
36
0cd946aa 37#line 32
4dd974da 38ok( 1, 'passing' );
39ok( 2, 'passing still' );
40ok( 3, 'still passing' );
41ok( 0, 'oh no!' );
42ok( 0, 'damnit' );
43
44
45END {
46 My::Test::ok($$out eq <<OUT);
471..5
48ok 1 - passing
49ok 2 - passing still
50ok 3 - still passing
51not ok 4 - oh no!
52not ok 5 - damnit
53OUT
54
cb26d8ba 55 My::Test::ok($$err =~ /Looks like you failed 2 tests of 5/);
4dd974da 56
57 # Prevent Test::Simple from exiting with non zero
58 exit 0;
59}