diff options
author | Andrew Ruthven <andrew@etc.gen.nz> | 2021-08-18 04:12:35 +0200 |
---|---|---|
committer | Andrew Ruthven <andrew@etc.gen.nz> | 2021-08-18 04:12:35 +0200 |
commit | 136c25e277302900abd4ea997ce28721c59b5676 (patch) | |
tree | 7f2461afd6381e23d4990d7501c8872eb5d40a0f /t/MyTest.pm |
Import libgnupg-interface-perl_1.02.orig.tar.gz
[dgit import orig libgnupg-interface-perl_1.02.orig.tar.gz]
Diffstat (limited to 't/MyTest.pm')
-rw-r--r-- | t/MyTest.pm | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/t/MyTest.pm b/t/MyTest.pm new file mode 100644 index 0000000..235d729 --- /dev/null +++ b/t/MyTest.pm @@ -0,0 +1,63 @@ +# MyTest.pm +# - module for use with test scripts +# +# Copyright (C) 2000 Frank J. Tobin <ftobin@cpan.org> +# +# This module is free software; you can redistribute it and/or modify it +# under the same terms as Perl itself. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# $Id: MyTest.pm,v 1.3 2001/08/21 13:31:50 ftobin Exp $ +# + +package MyTest; + +use strict; +use English qw( -no_match_vars ); +use Exporter; +use IO::File; +use vars qw( @ISA @EXPORT ); + +@ISA = qw( Exporter ); +@EXPORT = qw( TEST ); + +$OUTPUT_AUTOFLUSH = 1; + +print "1..", COUNT_TESTS(), "\n"; + +my $counter = 0; + +sub TEST ( & ) +{ + my ( $code ) = @_; + + $counter++; + + &$code or print "not "; + print "ok $counter\n"; +} + + +sub COUNT_TESTS +{ + my ( $file ) = @_; + $file ||= $PROGRAM_NAME; + + my $tests = 0; + + my $in = IO::File->new( $file ); + + while ( $_ = $in->getline() ) + { + $tests++ + if /^\s*TEST\s*/; + } + + return $tests; +} + + +1; |