Commit | Line | Data |
33459055 |
1 | #!perl -w |
ccbd73a4 |
2 | # $Id: /mirror/googlecode/test-more/t/fail.t 57943 2008-08-18T02:09:22.275428Z brooklyn.kid51 $ |
4dd974da |
3 | |
15db8fc4 |
4 | BEGIN { |
a9153838 |
5 | if( $ENV{PERL_CORE} ) { |
6 | chdir 't'; |
7 | @INC = ('../lib', 'lib'); |
8 | } |
9 | else { |
10 | unshift @INC, 't/lib'; |
11 | } |
15db8fc4 |
12 | } |
13 | |
33459055 |
14 | use strict; |
33459055 |
15 | |
16 | require Test::Simple::Catch; |
17 | my($out, $err) = Test::Simple::Catch::caught(); |
30e302f8 |
18 | local $ENV{HARNESS_ACTIVE} = 0; |
33459055 |
19 | |
20 | |
4dd974da |
21 | # Can't use Test.pm, that's a 5.005 thing. |
22 | package My::Test; |
23 | |
24 | print "1..2\n"; |
25 | |
26 | my $test_num = 1; |
27 | # Utility testing functions. |
28 | sub ok ($;$) { |
29 | my($test, $name) = @_; |
11ea77c5 |
30 | my $ok = ''; |
31 | $ok .= "not " unless $test; |
32 | $ok .= "ok $test_num"; |
33 | $ok .= " - $name" if defined $name; |
34 | $ok .= "\n"; |
35 | print $ok; |
4dd974da |
36 | $test_num++; |
37 | } |
38 | |
39 | |
40 | package main; |
41 | |
42 | require Test::Simple; |
4dd974da |
43 | Test::Simple->import(tests => 5); |
44 | |
33459055 |
45 | #line 35 |
4dd974da |
46 | ok( 1, 'passing' ); |
47 | ok( 2, 'passing still' ); |
48 | ok( 3, 'still passing' ); |
49 | ok( 0, 'oh no!' ); |
50 | ok( 0, 'damnit' ); |
51 | |
52 | |
53 | END { |
54 | My::Test::ok($$out eq <<OUT); |
55 | 1..5 |
56 | ok 1 - passing |
57 | ok 2 - passing still |
58 | ok 3 - still passing |
59 | not ok 4 - oh no! |
60 | not ok 5 - damnit |
61 | OUT |
62 | |
33459055 |
63 | My::Test::ok($$err eq <<ERR); |
b1ddf169 |
64 | # Failed test 'oh no!' |
b7f9bbeb |
65 | # at $0 line 38. |
b1ddf169 |
66 | # Failed test 'damnit' |
b7f9bbeb |
67 | # at $0 line 39. |
33459055 |
68 | # Looks like you failed 2 tests of 5. |
69 | ERR |
4dd974da |
70 | |
71 | # Prevent Test::Simple from exiting with non zero |
72 | exit 0; |
73 | } |