Commit | Line | Data |
15db8fc4 |
1 | BEGIN { |
a9153838 |
2 | if( $ENV{PERL_CORE} ) { |
3 | chdir 't'; |
4 | @INC = ('../lib', 'lib'); |
5 | } |
6 | else { |
7 | unshift @INC, 't/lib'; |
8 | } |
15db8fc4 |
9 | } |
10 | |
33459055 |
11 | # Can't use Test.pm, that's a 5.005 thing. |
4dd974da |
12 | package My::Test; |
13 | |
14 | print "1..12\n"; |
15 | |
16 | my $test_num = 1; |
17 | # Utility testing functions. |
18 | sub ok ($;$) { |
19 | my($test, $name) = @_; |
11ea77c5 |
20 | my $ok = ''; |
21 | $ok .= "not " unless $test; |
22 | $ok .= "ok $test_num"; |
23 | $ok .= " - $name" if defined $name; |
24 | $ok .= "\n"; |
25 | print $ok; |
4dd974da |
26 | $test_num++; |
27 | } |
28 | |
29 | |
30 | package main; |
31 | |
32 | require Test::Simple; |
33 | |
d020a79a |
34 | require Test::Simple::Catch; |
35 | my($out, $err) = Test::Simple::Catch::caught(); |
4dd974da |
36 | |
37 | eval { |
38 | Test::Simple->import; |
39 | }; |
40 | |
41 | My::Test::ok($$out eq ''); |
42 | My::Test::ok($$err eq ''); |
43 | My::Test::ok($@ eq ''); |
44 | |
45 | eval { |
46 | Test::Simple->import(tests => undef); |
47 | }; |
48 | |
49 | My::Test::ok($$out eq ''); |
50 | My::Test::ok($$err eq ''); |
51 | My::Test::ok($@ =~ /Got an undefined number of tests/); |
52 | |
53 | eval { |
54 | Test::Simple->import(tests => 0); |
55 | }; |
56 | |
57 | My::Test::ok($$out eq ''); |
58 | My::Test::ok($$err eq ''); |
33459055 |
59 | My::Test::ok($@ =~ /You said to run 0 tests!/); |
4dd974da |
60 | |
61 | eval { |
62 | Test::Simple::ok(1); |
63 | }; |
33459055 |
64 | My::Test::ok( $@ =~ /You tried to run a test without a plan!/); |
4dd974da |
65 | |
66 | |
67 | END { |
68 | My::Test::ok($$out eq ''); |
69 | My::Test::ok($$err eq ""); |
70 | |
71 | # Prevent Test::Simple from exiting with non zero. |
72 | exit 0; |
73 | } |