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(); |
17 | |
18 | |
4dd974da |
19 | # Can't use Test.pm, that's a 5.005 thing. |
20 | package My::Test; |
21 | |
22 | print "1..2\n"; |
23 | |
24 | my $test_num = 1; |
25 | # Utility testing functions. |
26 | sub ok ($;$) { |
27 | my($test, $name) = @_; |
11ea77c5 |
28 | my $ok = ''; |
29 | $ok .= "not " unless $test; |
30 | $ok .= "ok $test_num"; |
31 | $ok .= " - $name" if defined $name; |
32 | $ok .= "\n"; |
33 | print $ok; |
4dd974da |
34 | $test_num++; |
35 | } |
36 | |
37 | |
38 | package main; |
39 | |
40 | require Test::Simple; |
4dd974da |
41 | Test::Simple->import(tests => 5); |
42 | |
33459055 |
43 | #line 35 |
4dd974da |
44 | ok( 1, 'passing' ); |
45 | ok( 2, 'passing still' ); |
46 | ok( 3, 'still passing' ); |
47 | ok( 0, 'oh no!' ); |
48 | ok( 0, 'damnit' ); |
49 | |
50 | |
51 | END { |
52 | My::Test::ok($$out eq <<OUT); |
53 | 1..5 |
54 | ok 1 - passing |
55 | ok 2 - passing still |
56 | ok 3 - still passing |
57 | not ok 4 - oh no! |
58 | not ok 5 - damnit |
59 | OUT |
60 | |
33459055 |
61 | My::Test::ok($$err eq <<ERR); |
62 | # Failed test ($0 at line 38) |
63 | # Failed test ($0 at line 39) |
64 | # Looks like you failed 2 tests of 5. |
65 | ERR |
4dd974da |
66 | |
67 | # Prevent Test::Simple from exiting with non zero |
68 | exit 0; |
69 | } |