Commit | Line | Data |
adfe19db |
1 | { |
2 | my $__ntest; |
c07deaaf |
3 | my $__total; |
4 | |
5 | sub plan { |
6 | @_ == 2 or die "usage: plan(tests => count)"; |
7 | my $what = shift; |
8 | $what eq 'tests' or die "cannot plan anything but tests"; |
9 | $__total = shift; |
10 | defined $__total && $__total > 0 or die "need a positive number of tests"; |
11 | print "1..$__total\n"; |
12 | } |
13 | |
14 | sub skip { |
15 | my $reason = shift; |
16 | ++$__ntest; |
17 | print "ok $__ntest # skip: $reason\n" |
18 | } |
adfe19db |
19 | |
20 | sub ok ($;$$) { |
21 | local($\,$,); |
22 | my $ok = 0; |
23 | my $result = shift; |
24 | if (@_ == 0) { |
25 | $ok = $result; |
26 | } else { |
27 | $expected = shift; |
28 | if (!defined $expected) { |
29 | $ok = !defined $result; |
30 | } elsif (!defined $result) { |
31 | $ok = 0; |
32 | } elsif (ref($expected) eq 'Regexp') { |
0d0f8426 |
33 | die "using regular expression objects is not backwards compatible"; |
adfe19db |
34 | } else { |
35 | $ok = $result eq $expected; |
36 | } |
37 | } |
38 | ++$__ntest; |
39 | if ($ok) { |
40 | print "ok $__ntest\n" |
41 | } |
42 | else { |
43 | print "not ok $__ntest\n" |
44 | } |
45 | } |
46 | } |
47 | |
48 | 1; |