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