Debian lenny version packages
[pkg-perl] / deb-src / libtest-simple-perl / libtest-simple-perl-0.80 / t / harness_active.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 use Test::Simple::Catch;
16 my($out, $err) = Test::Simple::Catch::caught();
17
18
19 # Can't use Test.pm, that's a 5.005 thing.
20 package My::Test;
21
22 # This has to be a require or else the END block below runs before
23 # Test::Builder's own and the ending diagnostics don't come out right.
24 require Test::Builder;
25 my $TB = Test::Builder->create;
26 $TB->plan(tests => 4);
27
28 # Utility testing functions.
29 sub ok ($;$) {
30     return $TB->ok(@_);
31 }
32
33
34 sub main::err_ok ($) {
35     my($expect) = @_;
36     my $got = $err->read;
37
38     return $TB->is_eq( $got, $expect );
39 }
40
41
42 package main;
43
44 require Test::More;
45 Test::More->import(tests => 4);
46 Test::More->builder->no_ending(1);
47
48 {
49     local $ENV{HARNESS_ACTIVE} = 0;
50
51 #line 62
52     fail( "this fails" );
53     err_ok( <<ERR );
54 #   Failed test 'this fails'
55 #   at $0 line 62.
56 ERR
57
58 #line 72
59     is( 1, 0 );
60     err_ok( <<ERR );
61 #   Failed test at $0 line 72.
62 #          got: '1'
63 #     expected: '0'
64 ERR
65 }
66
67 {
68     local $ENV{HARNESS_ACTIVE} = 1;
69                    
70 #line 71
71     fail( "this fails" );
72     err_ok( <<ERR );
73
74 #   Failed test 'this fails'
75 #   at $0 line 71.
76 ERR
77
78
79 #line 84
80     is( 1, 0 );
81     err_ok( <<ERR );
82
83 #   Failed test at $0 line 84.
84 #          got: '1'
85 #     expected: '0'
86 ERR
87
88 }