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