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