File Coverage

tests/xemulator/class_methodmaker/Test.pm
Criterion Covered Total %
statement 21 31 67.7
branch 4 10 40.0
condition 1 3 33.3
subroutine 5 6 83.3
pod 0 3 0.0
total 31 53 58.4


line stmt bran cond sub pod time code
1             ######################################################################
2             #
3             # Please Note: This test module is deprecated, but included for
4             # compatibility with some of the older tests in this distribution.
5             #
6             ######################################################################
7              
8             package Test;
9              
10             #
11             # $Id: Test.pm,v 1.1 2000/04/26 04:29:41 recoil Exp $
12             #
13              
14             # COPYRIGHT NOTICE
15             #
16             # Copyright 1996 Organic Online, Inc. Title, ownership rights, and
17             # intellectual property rights in and to this software remain with
18             # Organic Online, Inc. Organic Online, Inc. hereby reserves all rights
19             # in and to this software. This software may not be copied, modified,
20             # or used without a license from Organic Online, Inc. This software is
21             # protected by international copyright laws and treaties, and may be
22             # protected by other law. Violation of copyright laws may result in
23             # civil liability and criminal penalties.
24              
25 35     35   37114 use strict;
  35         72  
  35         1467  
26              
27 35     35   255 use Exporter;
  35         491  
  35         2172  
28 35     35   344 use vars qw ( @ISA @EXPORT );
  35         62  
  35         38230  
29             @ISA = qw ( Exporter );
30             @EXPORT = qw ( TEST COUNT_TESTS PRINT_TEST_HEADER find_test );
31              
32             my $COUNTER = 0;
33              
34             $| = 1;
35             print "1..", &COUNT_TESTS(), "\n" unless $0 =~ /^-e/;
36              
37             sub TEST (&) {
38 566     566 0 5403 my ($code) = @_;
39 566         857 $COUNTER++;
40 566 50       1290 &$code or print "not ";
41 566         84806 print "ok $COUNTER\n";
42             }
43              
44             sub COUNT_TESTS {
45 35     35 0 64 my ($file) = @_;
46 35   33     403 $file ||= $0;
47 35         47 my $c = 0;
48 35 50       2124 open(IN, $file) or die "Can't open $file: $!";
49 35         588 while () {
50 2192 100       4762 /^\s*#/ and next;
51 2067         6901 $c += s/(TEST\s{)/$1/g;
52             }
53 35         26522 $c;
54             }
55              
56             sub find_test ($@) {
57 0     0 0   my ($file, @numbers) = @_;
58 0 0         open(T, $file) or die "Can't open $file: $!";
59 0           local $/ = undef;
60 0           my $content = ;
61 0           my $c = 0;
62 0           my %tests = map { ++$c, $_ } $content =~ /\nTEST\s+{.*?};/gs;
  0            
63 0 0         @numbers or @numbers = (1 .. $c);
64 0           foreach (@numbers) {
65 0           print "#$_: $tests{$_}\n";
66             }
67             }
68            
69              
70              
71             1;
72              
73             __END__