Commit | Line | Data |
33459055 |
1 | #!perl -w |
4dd974da |
2 | |
15db8fc4 |
3 | BEGIN { |
a9153838 |
4 | if( $ENV{PERL_CORE} ) { |
5 | chdir 't'; |
6 | @INC = ('../lib', 'lib'); |
7 | } |
8 | else { |
9 | unshift @INC, 't/lib'; |
10 | } |
15db8fc4 |
11 | } |
12 | |
33459055 |
13 | use strict; |
33459055 |
14 | |
15 | require Test::Simple::Catch; |
16 | my($out, $err) = Test::Simple::Catch::caught(); |
30e302f8 |
17 | local $ENV{HARNESS_ACTIVE} = 0; |
33459055 |
18 | |
19 | |
4dd974da |
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) = @_; |
11ea77c5 |
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; |
4dd974da |
35 | $test_num++; |
36 | } |
37 | |
38 | |
39 | package main; |
40 | |
41 | require Test::Simple; |
4dd974da |
42 | Test::Simple->import(tests => 5); |
43 | |
33459055 |
44 | #line 35 |
4dd974da |
45 | ok( 1, 'passing' ); |
46 | ok( 2, 'passing still' ); |
47 | ok( 3, 'still passing' ); |
48 | ok( 0, 'oh no!' ); |
49 | ok( 0, 'damnit' ); |
50 | |
51 | |
52 | END { |
53 | My::Test::ok($$out eq <<OUT); |
54 | 1..5 |
55 | ok 1 - passing |
56 | ok 2 - passing still |
57 | ok 3 - still passing |
58 | not ok 4 - oh no! |
59 | not ok 5 - damnit |
60 | OUT |
61 | |
33459055 |
62 | My::Test::ok($$err eq <<ERR); |
b1ddf169 |
63 | # Failed test 'oh no!' |
b7f9bbeb |
64 | # at $0 line 38. |
b1ddf169 |
65 | # Failed test 'damnit' |
b7f9bbeb |
66 | # at $0 line 39. |
33459055 |
67 | # Looks like you failed 2 tests of 5. |
68 | ERR |
4dd974da |
69 | |
70 | # Prevent Test::Simple from exiting with non zero |
71 | exit 0; |
72 | } |