Commit | Line | Data |
7483b81c |
1 | #!/usr/bin/perl -w |
2 | |
3 | BEGIN { |
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. |
12 | package My::Test; |
13 | |
14 | print "1..7\n"; |
15 | |
16 | my $test_num = 1; |
17 | # Utility testing functions. |
18 | sub 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 | |
32 | sub 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 | |
52 | use Test::More import => ['plan']; |
53 | |
54 | ok !eval { plan tests => 'no_plan'; }; |
55 | is $@, "Number of tests must be a postive integer. You gave it 'no_plan'.\n"; |
56 | |
57 | my $foo = []; |
58 | my @foo = ($foo, 2, 3); |
59 | ok !eval { plan tests => @foo }; |
60 | is $@, "Number of tests must be a postive integer. You gave it '$foo'.\n"; |
61 | |
62 | ok !eval { plan tests => 0 }; |
63 | ok !eval { plan tests => -1 }; |
64 | ok !eval { plan tests => '' }; |