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