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