Commit | Line | Data |
---|---|---|
30e302f8 | 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 | ||
b1ddf169 | 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); | |
30e302f8 | 27 | |
30e302f8 | 28 | # Utility testing functions. |
29 | sub ok ($;$) { | |
b1ddf169 | 30 | return $TB->ok(@_); |
30e302f8 | 31 | } |
32 | ||
33 | ||
0257f296 | 34 | sub main::err_ok ($) { |
30e302f8 | 35 | my($expect) = @_; |
36 | my $got = $err->read; | |
37 | ||
b1ddf169 | 38 | return $TB->is_eq( $got, $expect ); |
30e302f8 | 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" ); | |
0257f296 | 53 | err_ok( <<ERR ); |
b1ddf169 | 54 | # Failed test 'this fails' |
b7f9bbeb | 55 | # at $0 line 62. |
30e302f8 | 56 | ERR |
57 | ||
58 | #line 72 | |
59 | is( 1, 0 ); | |
0257f296 | 60 | err_ok( <<ERR ); |
b7f9bbeb | 61 | # Failed test at $0 line 72. |
30e302f8 | 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" ); | |
0257f296 | 72 | err_ok( <<ERR ); |
30e302f8 | 73 | |
b1ddf169 | 74 | # Failed test 'this fails' |
b7f9bbeb | 75 | # at $0 line 71. |
30e302f8 | 76 | ERR |
77 | ||
78 | ||
79 | #line 84 | |
80 | is( 1, 0 ); | |
0257f296 | 81 | err_ok( <<ERR ); |
30e302f8 | 82 | |
b7f9bbeb | 83 | # Failed test at $0 line 84. |
30e302f8 | 84 | # got: '1' |
85 | # expected: '0' | |
86 | ERR | |
87 | ||
88 | } |