Clear up test based on line number differences between the core and the
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / plan_bad.t
CommitLineData
7483b81c 1#!/usr/bin/perl -w
2
3BEGIN {
4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = '../lib';
7 }
8}
9
10
11# Can't use Test.pm, that's a 5.005 thing.
12package My::Test;
13
14print "1..7\n";
15
16my $test_num = 1;
17# Utility testing functions.
18sub ok ($;$) {
19 my($test, $name) = @_;
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;
26 $test_num++;
27
28 return $test;
29}
30
31
32sub is ($$;$) {
33 my($this, $that, $name) = @_;
34 my $test = $this eq $that;
35 my $ok = '';
36 $ok .= "not " unless $test;
37 $ok .= "ok $test_num";
38 $ok .= " - $name" if defined $name;
39 $ok .= "\n";
40 print $ok;
41
42 unless( $test ) {
43 print "# got \n$this";
44 print "# expected \n$that";
45 }
46 $test_num++;
47
48 return $test;
49}
50
51
52use Test::More import => ['plan'];
53
54ok !eval { plan tests => 'no_plan'; };
55is $@, "Number of tests must be a postive integer. You gave it 'no_plan'.\n";
56
57my $foo = [];
58my @foo = ($foo, 2, 3);
59ok !eval { plan tests => @foo };
60is $@, "Number of tests must be a postive integer. You gave it '$foo'.\n";
61
62ok !eval { plan tests => 0 };
63ok !eval { plan tests => -1 };
64ok !eval { plan tests => '' };