Commit | Line | Data |
4dd974da |
1 | # Can't use Test.pm, that's a 5.005 thing. |
2 | package My::Test; |
3 | |
4 | print "1..2\n"; |
5 | |
6 | my $test_num = 1; |
7 | # Utility testing functions. |
8 | sub ok ($;$) { |
9 | my($test, $name) = @_; |
11ea77c5 |
10 | my $ok = ''; |
11 | $ok .= "not " unless $test; |
12 | $ok .= "ok $test_num"; |
13 | $ok .= " - $name" if defined $name; |
14 | $ok .= "\n"; |
15 | print $ok; |
4dd974da |
16 | $test_num++; |
17 | } |
18 | |
19 | |
20 | package main; |
21 | |
22 | require Test::Simple; |
23 | |
12b8e1e4 |
24 | @INC = ('../lib', 'lib/Test/Simple'); |
4dd974da |
25 | require Catch; |
26 | my($out, $err) = Catch::caught(); |
27 | |
28 | Test::Simple->import(tests => 3); |
29 | |
30 | ok(1, 'Foo'); |
31 | ok(0, 'Bar'); |
32 | ok(1, 'Yar'); |
33 | ok(1, 'Car'); |
34 | ok(0, 'Sar'); |
35 | |
36 | END { |
37 | My::Test::ok($$out eq <<OUT); |
38 | 1..3 |
39 | ok 1 - Foo |
40 | not ok 2 - Bar |
41 | ok 3 - Yar |
42 | ok 4 - Car |
43 | not ok 5 - Sar |
44 | OUT |
45 | |
46 | My::Test::ok($$err eq <<ERR); |
11ea77c5 |
47 | # Failed test ($0 at line 31) |
48 | # Failed test ($0 at line 34) |
4dd974da |
49 | # Looks like you planned 3 tests but ran 2 extra. |
50 | ERR |
51 | |
52 | exit 0; |
53 | } |