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