Debian lenny version packages
[pkg-perl] / deb-src / libtest-simple-perl / libtest-simple-perl-0.80 / t / fail_one.t
1 #!/usr/bin/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     return $test ? 1 : 0;
38 }
39
40
41 package main;
42
43 require Test::Simple;
44 Test::Simple->import(tests => 1);
45
46 #line 45
47 ok(0);
48
49 END {
50     My::Test::ok($$out eq <<OUT);
51 1..1
52 not ok 1
53 OUT
54
55     My::Test::ok($$err eq <<ERR) || print $$err;
56 #   Failed test at $0 line 45.
57 # Looks like you failed 1 test of 1.
58 ERR
59
60     # Prevent Test::Simple from existing with non-zero
61     exit 0;
62 }