Test-Assertions-1.054/0000755016521500001460000000000010466660313016227 5ustar andrewwtechnical00000000000000Test-Assertions-1.054/t/0000755016521500001460000000000010466660313016472 5ustar andrewwtechnical00000000000000Test-Assertions-1.054/t/pod_coverage.t0000644016521500001460000000200010466660244021307 0ustar andrewwtechnical00000000000000#!/usr/local/bin/perl use Test::More; use File::Spec; use lib './lib'; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD Coverage" if($@); # dir may be zero length on win32 (indicating current directory) my $dir = File::Spec->catdir ( (File::Spec->splitpath($0))[1], File::Spec->updir()); if(defined $dir && length $dir) { chdir($dir) or die "Couldn't change to project dir ($dir)"; } #AppsIflRunner is a wrapper around ModperlRunner and CGIRunner, so its interface is documented in those modules @modules = grep {$_ !~ /^AppsIflRunner$/} Test::Pod::Coverage::all_modules() or plan skip_all => "No modules to test"; plan tests => scalar @modules; for my $module (@modules) { my @private = (qr/^[A-Z_]+$/); @private = (qr/^tests$/, qr/^ASSERT_/, qr/^TRACE|HAVE_ALARM$/) if($module eq 'Test::Assertions'); @private = (qr/^deep_import$/) if($module eq 'Log::Trace'); pod_coverage_ok($module, { also_private => \@private }); #Ignore all caps } Test-Assertions-1.054/t/Test-Assertions-TestScript.t0000644016521500001460000000137710466660244024043 0ustar andrewwtechnical00000000000000#!/usr/local/bin/perl -w # We want to use the development version of T::A::TestScript use File::Spec::Functions qw( :ALL ); BEGIN { if ($0) { my ($vol, $dir, $file) = splitpath(rel2abs($0)); my @parent_dir = splitdir(canonpath($dir)); pop @parent_dir; my $lib_dir = catpath($vol, catdir(@parent_dir,'lib'), ''); unshift @INC, $lib_dir; } else { die "Could not find script location\n"; } } use vars qw($opt_b); use Test::Assertions::TestScript(options => {'b', \$opt_b}); ASSERT($Test::Assertions::TestScript::VERSION, "Compiled version $Test::Assertions::TestScript::VERSION"); TRACE("Sample trace message to test -t option"); ASSERT(1, "Correctly generates test output"); TRACE("Command-line -b option set \$opt_b variable", $opt_b); sub TRACE{} Test-Assertions-1.054/t/fails.pl0000644016521500001460000000012410466660244020125 0ustar andrewwtechnical00000000000000#!/usr/local/bin/perl print "1..3\n"; print "ok\n"; print "not ok\n"; print "ok\n"; Test-Assertions-1.054/t/Test-Assertion_style.pl0000644016521500001460000000031210466660244023132 0ustar andrewwtechnical00000000000000#!/usr/local/bin/perl use strict; use lib qw(./lib ../lib); use Test::Assertions shift(); Test::Assertions::plan tests => 1; go(); sub go { to(); } sub to { #line 100 ASSERT(0, 'deliberatefail'); } Test-Assertions-1.054/t/pod.t0000644016521500001460000000020110466660247017440 0ustar andrewwtechnical00000000000000use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Test-Assertions-1.054/t/Test-Assertions.t0000644016521500001460000001532710466660244021741 0ustar andrewwtechnical00000000000000#!/usr/local/bin/perl # # Unit test for Test::Assertions # $Id: Test-Assertions.t,v 1.21 2006/01/20 12:22:12 tims Exp $ # # Options: # -s : save output files # use strict; use lib qw(./lib ../lib); use Test::Assertions qw(test); use Getopt::Std; use vars qw($opt_s); #Options getopts("s"); #Test data my $lhs = {0=>1, b=>2, c=>3}; my $rhs = {}; $rhs->{c}=3; $rhs->{b}=2; $rhs->{0}=1; #Files generated by this test my $file1 = 'Test-Assertions.1'; my $file2 = 'Test-Assertions.2'; my $file3 = 'Test-Assertions_child_1.pl'; #Ensure any preserved output files are cleaned away unlink($file1, $file2, $file3); die("Unable to clean up output files") if(-e $file1 || -e $file2 || -e $file3); #Tests plan tests => 57; chdir('t') if -d 't'; ASSERT(1, 'compiled'); # # Test/ok mode # import Test::Assertions qw(test/ok); ok(1); # # DIED function # ASSERT(DIED(sub {die()} ), 'die() is detected'); # # Assess functions # ASSERT(ASSESS_FILE("perl fails.pl") =~ /not ok/, 'a failing script is seen as failing'); ASSERT(ASSESS(["not ok"]) =~ /not ok/, 'check that "not ok" is assessed ok'); ASSERT(ASSESS(["ok"]) !~ /not ok/, 'check that "ok" is assessed ok'); ASSERT(ASSESS(["1..3","ok","ok"]) =~ /not ok/, 'check that wrong number of tests is not ok'); my @list = ASSESS(["not ok"], "assess in list context"); ASSERT(!$list[0], $list[1]); @list = ASSESS(["ok"], "assess in list context"), ASSERT($list[0], $list[1]); # # Test the EQUAL function # ASSERT( EQUAL($lhs, $rhs), 'deep comparisons' ); ASSERT( EQUAL(15, 0x0F), 'scalars' ); ASSERT( EQUAL('hello', 'hello'), 'scalars' ); ASSERT( ! EQUAL('hello', 'world'), 'scalars' ); ASSERT( EQUAL([1, 3, 'e', 't'], [1, 3, 'e', 't']), 'array refs' ); ASSERT( ! EQUAL([1, 3, 'e', 't'], [3, 1, 'e', 't']), 'array refs' ); ASSERT( EQUAL( { hello => 'world', 234 => 'whoo!!', 'blah blah' => '', }, { hello => 'world', 'blah blah' => '', 234 => 'whoo!!', }), 'hash refs' ); ASSERT( ! EQUAL( { hello => 'world', 234 => 'whoo!!', 'blah blah' => '', }, { hello => 'world', 234 => 'whoo!!', }), 'hash refs' ); # # FILES_EQUAL # ASSERT( ! FILES_EQUAL($file1, $file2), 'FILES_EQUAL works on nonexistent files'); WRITE_FILE($file1, ''); WRITE_FILE($file2, ''); ASSERT( -e $file1, 'file written'); ASSERT( -e $file2, 'file written'); ASSERT( FILES_EQUAL($file1, $file2), 'FILES_EQUAL works on zero-sized files'); WRITE_FILE($file1, 'hello'); WRITE_FILE($file2, 'world'); ASSERT( ! FILES_EQUAL($file1, $file2), 'FILES_EQUAL works on nonzero-sized files'); WRITE_FILE($file1, 'hello'); WRITE_FILE($file2, 'hello'); ASSERT( FILES_EQUAL($file1, $file2), 'FILES_EQUAL works on nonzero-sized files'); # # EQUALS_FILE # unlink($file1, $file2); WRITE_FILE($file1, ''); ASSERT( EQUALS_FILE('', $file1), 'EQUALS_FILE works on zero-sized files'); WRITE_FILE($file1, 'hello'); ASSERT( ! EQUALS_FILE('world', $file1), 'EQUALS_FILE works on nonzero-sized files'); WRITE_FILE($file1, 'hello'); ASSERT( EQUALS_FILE('hello', $file1), 'EQUALS_FILE works on nonzero-sized files'); # # MATCHES_FILE # unlink($file1, $file2); WRITE_FILE($file1, ''); ASSERT( MATCHES_FILE('', $file1), 'MATCHES_FILE works on zero-sized files'); WRITE_FILE($file1, 'Y\wZ'); ASSERT( ! MATCHES_FILE('LHR', $file1), 'MATCHES_FILE works on nonzero-sized files'); WRITE_FILE($file1, 'Y\wZ'); ASSERT( ! MATCHES_FILE('Callsign YYZ OK', $file1), 'MATCHES_FILE works on nonzero-sized files'); ASSERT( MATCHES_FILE('YYZ', $file1), 'MATCHES_FILE works on nonzero-sized files'); # # READ_FILE and WRITE_FILE # WRITE_FILE($file3, 'use strict;use lib qw(./lib ../lib); use Test::Assertions qw(test); plan tests => 2; ASSERT(1,"OK");ASSERT(1,"OK");'); system("$^X $file3 > $file1 2> $file2"); ASSERT( scalar(READ_FILE($file1) =~ m/1\.\.2.*ok 1.*ok 2/s), "child process writes to $file1"); ASSERT( ! -s $file2, "child process writes nothing to $file2"); WRITE_FILE($file3, 'use strict;use lib qw(./lib ../lib); use Test::Assertions qw(test); plan tests => 2; ASSERT(1);'); system("$^X $file3 > $file1 2> $file2"); ASSERT( scalar(READ_FILE($file1) =~ m/1\.\.2.*ok 1/s), "child process writes to $file1"); ASSERT( scalar(READ_FILE($file2) =~ m/# Looks like.*2.*1/s), "child process writes to $file2"); # plan tests with a chdir WRITE_FILE($file3, 'use strict;use lib qw(./lib ../lib); use Test::Assertions qw(test); chdir(".."); plan tests; #ASSERT(0) ASSERT(1);'); system("$^X $file3 > $file1 2> $file2"); ASSERT( scalar(READ_FILE($file1) =~ m/1\.\.1.*ok 1/s), "child process writes to $file1"); ASSERT( length(READ_FILE($file2)) == 0, "child process writes nothing to $file2"); WRITE_FILE($file3, 'use strict;use lib qw(./lib ../lib); use Test::Assertions qw(warn); ASSERT(1,"OK");'); system("$^X $file3 > $file1 2> $file2"); ASSERT( ! -s $file1, "child process writes nothing to $file1"); ASSERT( ! -s $file2, "child process writes nothing to $file2"); my $rv = WRITE_FILE($file1, 'hello world 123'); ASSERT($rv == 1, 'file was written'); ASSERT((-e $file1), 'file was written'); ASSERT( WRITE_FILE($file1, 'hello world 123'), 'file was written'); $rv = READ_FILE($file1); ASSERT($rv eq 'hello world 123', 'file was read OK'); ASSERT( READ_FILE($file1), 'file was read OK' ); ASSERT( READ_FILE($file1) eq 'hello world 123', 'file was read OK' ); $rv = READ_FILE('nonexistent.YYZ'); chomp($@); ASSERT(! defined $rv, "file was not read: $@"); # # Different styles # $rv = system("$^X Test-Assertion_style.pl die > $file1 2> $file2"); ASSERT($rv != 0, "child exited not OK"); ASSERT( scalar(READ_FILE($file1) eq "1\.\.1\n"), "child process writes to $file1"); ASSERT( scalar(READ_FILE($file2) =~ m/Assertion failure at line 100 in.*deliberatefail\)\s*$/s), "child process writes to $file2"); $rv = system("$^X Test-Assertion_style.pl warn > $file1 2> $file2"); ASSERT($rv == 0, "child exited OK"); ASSERT( scalar(READ_FILE($file1) eq "1\.\.1\n"), "child process writes to $file1"); ASSERT( scalar(READ_FILE($file2) =~ m/Assertion failure at line 100 in.*deliberatefail\)\s*$/s), "child process writes to $file2"); $rv = system("$^X Test-Assertion_style.pl confess > $file1 2> $file2"); ASSERT($rv != 0, "child exited not OK"); ASSERT( scalar(READ_FILE($file1) eq "1\.\.1\n"), "child process writes to $file1"); ASSERT( scalar(READ_FILE($file2) =~ m/Assertion failure at line 9 in.*deliberatefail.*ASSERT_confess.*called at.*main::to.*called at.*main::go.*called at/s), "child process writes to $file2"); $rv = system("$^X Test-Assertion_style.pl cluck > $file1 2> $file2"); ASSERT($rv == 0, "child exited OK"); ASSERT( scalar(READ_FILE($file1) eq "1\.\.1\n"), "child process writes to $file1"); ASSERT( scalar(READ_FILE($file2) =~ m/Assertion failure at line 9 in.*deliberatefail.*ASSERT_cluck.*called at.*main::to.*called at.*main::go.*called at/s), "child process writes to $file2"); # # Clean up # unlink($file1, $file2, $file3) unless($opt_s); Test-Assertions-1.054/lib/0000755016521500001460000000000010466660313016775 5ustar andrewwtechnical00000000000000Test-Assertions-1.054/lib/Test/0000755016521500001460000000000010466660313017714 5ustar andrewwtechnical00000000000000Test-Assertions-1.054/lib/Test/Assertions.pm0000644016521500001460000004010010466660244022402 0ustar andrewwtechnical00000000000000package Test::Assertions; use strict; @Test::Assertions::EXPORT = qw(DIED COMPILES EQUAL EQUALS_FILE MATCHES_FILE FILES_EQUAL ASSESS ASSESS_FILE INTERPRET tests READ_FILE WRITE_FILE); $Test::Assertions::VERSION = sprintf"%d.%03d", q$Revision: 1.54 $ =~ /: (\d+)\.(\d+)/; #Define constants #(avoid "use constant" to cut compile-time overhead slightly - it *is* measurable) BEGIN { *tests = sub () {1}; # constant to export *HAVE_ALARM = sub () {1}; # a flag, so that alarm() is never called if it isn't present (e.g. on Windows) eval { my $was = alarm 0; alarm $was; }; undef *HAVE_ALARM, *HAVE_ALARM = sub () {0} if($@); #Change the constant! } # this is the number of the current test, for automatically # numbering the output of ASSERT $Test::Assertions::test_no = 0; # this is a flag - true if we are imported in a testing mode $Test::Assertions::test_mode = 0; sub import { my $pkg = shift; my $style = shift; my $callpkg = caller(0); no strict 'refs'; foreach my $sym (@Test::Assertions::EXPORT) { *{"$callpkg\::$sym"} = \&{"$pkg\::$sym"}; } #Select implementation of ASSERT if(!$style) { *{"$callpkg\::ASSERT"} = sub {}; } elsif($style eq 'die') { *{"$callpkg\::ASSERT"} = \&{"$pkg\::ASSERT_die"}; } elsif($style eq 'warn') { *{"$callpkg\::ASSERT"} = \&{"$pkg\::ASSERT_warn"}; } elsif($style eq 'confess') { *{"$callpkg\::ASSERT"} = \&{"$pkg\::ASSERT_confess"}; } elsif($style eq 'cluck') { *{"$callpkg\::ASSERT"} = \&{"$pkg\::ASSERT_cluck"}; } elsif($style eq 'test' || $style eq 'test/ok') { require File::Spec; $Test::Assertions::calling_script = File::Spec->rel2abs($0); $Test::Assertions::use_ok = $style eq 'test/ok'; *{"$callpkg\::ASSERT"} = \&{"$pkg\::ASSERT_test"}; *{"$callpkg\::ok"} = \&{"$pkg\::ASSERT_test"} if($style eq 'test/ok'); *{"$callpkg\::plan"} = \&{"$pkg\::plan"}; *{"$callpkg\::ignore"} = \&{"$pkg\::ignore"}; *{"$callpkg\::only"} = \&{"$pkg\::only"}; $Test::Assertions::test_mode = 1; } else { croak("Test::Assertions imported with unknown directive: $style"); } } #For compatibility with Test::Simple sub plan { shift(); #tests my $number = shift(); $number = _count_tests($Test::Assertions::calling_script) unless (defined($number) && $number =~ /^\d+$/); print "1..$number\n"; $Test::Assertions::planned_tests = $number; return $number; } END { # if we're in test mode and plan() has been called, ensure that the right number of tests have been run if ($Test::Assertions::test_mode && defined($Test::Assertions::planned_tests)) { if ($Test::Assertions::test_no != $Test::Assertions::planned_tests) { warn "# Looks like you planned $Test::Assertions::planned_tests tests but actually ran $Test::Assertions::test_no.\n"; } } } #Test filtering sub ignore { %Test::Assertions::ignore = map {$_ => 1} @_; } sub only { %Test::Assertions::only = map {$_ => 1} @_; } # # Various styles # sub ASSERT_test ($;$) { my ($test,$msg) = @_; my ($pkg, $filename, $line, $sub) = caller(0); $Test::Assertions::test_no++; if($Test::Assertions::ignore{$Test::Assertions::test_no} || %Test::Assertions::only && !$Test::Assertions::only{$Test::Assertions::test_no}) { print "ok - skipped $Test::Assertions::test_no"; } else { print ($test?"ok $Test::Assertions::test_no":"not ok $Test::Assertions::test_no at line $line in $filename"); } print " ($msg)" if(defined $msg); print "\n"; } sub ASSERT_die ($;$) { my $test = shift; my $msg = shift; $msg="($msg)" if(defined $msg); my ($pkg, $filename, $line, $sub) = caller(0); die("Assertion failure at line $line in $filename $msg\n") unless($test); } sub ASSERT_warn ($;$) { my $test = shift; my $msg = shift; $msg="($msg)" if(defined $msg); my ($pkg, $filename, $line, $sub) = caller(0); warn("Assertion failure at line $line in $filename $msg\n") unless($test); } sub ASSERT_confess ($;$) { my $test = shift; my $msg = shift; require Carp; $msg="($msg)" if(defined $msg); my ($pkg, $filename, $line, $sub); if (caller(1)) { ($pkg, $filename, $line, $sub) = caller(1); } else { ($pkg, $filename, $line, $sub) = caller(0); } Carp::confess("Assertion failure at line $line in $filename $msg\n") unless($test); } sub ASSERT_cluck ($;$) { my $test = shift; my $msg = shift; require Carp; $msg="($msg)" if(defined $msg); my ($pkg, $filename, $line, $sub); if (caller(1)) { ($pkg, $filename, $line, $sub) = caller(1); } else { ($pkg, $filename, $line, $sub) = caller(0); } Carp::cluck("Assertion failure at line $line in $filename $msg\n") unless($test); } sub DIED { my ($coderef) = @_; eval {&$coderef}; my $error = $@; TRACE("DIED: " . $error); return $error; } sub COMPILES { my ($file, $strict, $strref) = @_; my @args = ($^X); push @args, '-Mstrict', '-w' if $strict; push @args, '-c', $file; my $output; my $ok = 0; if ($strref && ref($strref) eq 'SCALAR') { require IO::CaptureOutput; ($output, $$strref) = IO::CaptureOutput::capture_exec(@args); $ok = ($$strref =~ /syntax OK/); } else { my $command = join ' ', @args; $output = `$command 2>&1`; $output =~ s/\n$//; $ok = ($output =~ /syntax OK/); } return wantarray? ($ok, $output) : $ok; } sub EQUAL { require Test::More; my ($lhs, $rhs) = @_; return Test::More::eq_array([$lhs],[$rhs]); } sub FILES_EQUAL { require File::Compare; my ($lhs, $rhs) = @_; return File::Compare::compare($lhs,$rhs)==0; } sub EQUALS_FILE { my ($lhs, $rhs) = @_; return($lhs eq _read_file($rhs)); } sub MATCHES_FILE { my ($lhs, $rhs) = @_; my $regex = _read_file($rhs); return($lhs =~ /^$regex$/); } sub ASSESS_FILE { my ($file, $verbose, $timeout) = @_; $timeout = 60 unless(defined $timeout); my @tests; local *FH; eval { alarm $timeout if HAVE_ALARM; open (*FH, "$file |") or die("unable to execute $file - $!"); @tests = ; close FH; }; alarm 0 if HAVE_ALARM; my $rs; if($@) { $rs = "not ok for $file ($@)\n" } elsif ($?) { $rs = "not ok for $file (exit code = $?)\n"; } else { $rs = ASSESS(\@tests, $file, $verbose); } return wantarray? INTERPRET($rs) : $rs; } sub ASSESS { my ($tests, $name, $verbose) = @_; my $errors = 0; my $total = 0; my $expected; if (${$tests}[0] =~ m/^1\.\.(\d+)$/) { $expected = $1; } else { $expected = -1; } foreach(@$tests) { if(/^not ok/) { $errors++; $total++; if($verbose) { s/\n?$/ in $name\n/; print; } } elsif(/^ok/) { $total++; } } my $rs; if(defined $name) { $name = " for $name"; } else { $name = ''; } if($errors) { $rs = "not ok$name ($errors errors in $total tests)\n"; } elsif($expected != -1 && $total != $expected) { $rs = "not ok$name (Expected $expected tests, ran $total tests)\n"; } else { $rs = "ok$name".($verbose?" passed all $total tests ":"")."\n"; } return wantarray? INTERPRET($rs) : $rs; } sub INTERPRET { my $rs = shift; my ($status, $desc) = ($rs =~ /^((?:not )?ok)(.*)$/); $desc =~ s/^\s+//; $desc =~ s/^for //; #ok for x => x $desc =~ s/^- //; #ok - x => x $desc =~ s/^\((.*)\)/$1/; #ok (x) => x return ($status eq 'ok' || 0, $desc); } sub READ_FILE { my $filename = shift; my $contents; eval { $contents = _read_file($filename); }; return $contents; } sub WRITE_FILE { my ($filename, $contents) = @_; my $success; eval { _write_file($filename, $contents); $success = 1; }; return $success; } # Misc subroutines sub _count_tests { my $filename = shift; my $count = 0; local *LI; open (LI, $filename) || die ("Unable to open $filename to count tests - $!"); while(
  • ) { s/\#.+//; # ignore commented-out lines $count++ if(/\bASSERT[\s\(]/); $count++ if($Test::Assertions::use_ok && /\bok[\s\(]/); } close LI; return $count; } sub _read_file { my $filename = shift; open (FH, $filename) || die("unable to open $filename - $!"); local $/ = undef; my $data = ; close FH; return $data; } sub _write_file { my ($filename, $data) = @_; local *FH; open(FH, ">$filename") or die("Unable to open $filename - $!"); binmode FH; print FH $data; close FH; } #Standard debugging stub - intended to be overridden when #debugging is needed, e.g. by Log::Trace sub TRACE {} 1; __END__ =head1 NAME Test::Assertions - a simple set of building blocks for both unit and runtime testing =head1 SYNOPSIS #ASSERT does nothing use Test::Assertions; #ASSERT warns "Assertion failure"... use Test::Assertions qw(warn); #ASSERT dies with "Assertion failure"... use Test::Assertions qw(die); #ASSERT warns "Assertion failure"... with stack trace use Test::Assertions qw(cluck); #ASSERT dies with "Assertion failure"... with stack trace use Test::Assertions qw(confess); #ASSERT prints ok/not ok use Test::Assertions qw(test); #Will cause an assertion failure ASSERT(1 == 0); #Optional message ASSERT(0 == 1, "daft"); #Checks if coderef dies ASSERT( DIED( sub {die()} ) ); #Check if perl compiles OK ASSERT( COMPILES('program.pl') ); #Deep comparisons ASSERT( EQUAL(\@a, \@b), "lists of widgets match" # an optional message ); ASSERT( EQUAL(\%a, \%b) ); #Compare to a canned value ASSERT( EQUALS_FILE($foo, 'bar.dat'), "value matched stored value" ); #Compare to a canned value (regex match using file contents as regex) ASSERT( MATCHES_FILE($foo, 'bar.regex') ); #Compare file contents ASSERT( FILES_EQUAL('foo.dat', 'bar.dat') ); #returns 'not ok for Foo::Bar Tests (1 errors in 3 tests)' ASSESS( ['ok 1', 'not ok 2', 'A comment', 'ok 3'], 'Foo::Bar Tests', 0 ); #Collate results from another test script ASSESS_FILE("test.pl"); #File routines $success = WRITE_FILE('bar.dat', 'hello world'); ASSERT( WRITE_FILE('bar.dat', 'hello world'), 'file was written'); $string = READ_FILE('example.out'); ASSERT( READ_FILE('example.out'), 'file has content' ); The helper routines don't need to be used inside ASSERT(): if ( EQUALS_FILE($string, $filename) ) { print "File hasn't changed - skipping\n"; } else { my $rc = run_complex_process($string); print "File changed - string was reprocessed with result '$rc'\n"; } ($boolean, $output) = COMPILES('file.pl'); # or... my $string; ($boolean, $standard_output) = COMPILES('file.pl', 1, \$string); # $string now contains standard error, separate from $standard_output In test mode: use Test::Assertions qw(test); plan tests => 4; plan tests; #will attempt to deduce the number only (1,2); #Only report ok/not ok for these tests ignore 2; #Skip this test #In test/ok mode... use Test::Assertions qw(test/ok); ok(1); #synonym for ASSERT =head1 DESCRIPTION Test::Assertions provides a convenient set of tools for constructing tests, such as unit tests or run-time assertion checks (like C's ASSERT macro). Unlike some of the Test:: modules available on CPAN, Test::Assertions is not limited to unit test scripts; for example it can be used to check output is as expected within a benchmarking script. When it is used for unit tests, it generates output in the standard form for CPAN unit testing (under Test::Harness). The package's import method is used to control the behaviour of ASSERT: whether it dies, warns, prints 'ok'/'not ok', or does nothing. In 'test' mode the script also exports plan(), only() and ignore() functions. In 'test/ok' mode an ok() function is also exported for compatibility with Test/Test::Harness. The plan function attempts to count the number of tests if it isn't told a number (this works fine in simple test scripts but not in loops/subroutines). In either mode, a warning will be emitted if the planned number of tests is not the same as the number of tests actually run, e.g. # Looks like you planned 2 tests but actually ran 1. =head2 METHODS =over 4 =item plan $number_of_tests Specify the number of tests to expect. If $number_of_tests isn't supplied, ASSERTION tries to deduce the number itself by parsing the calling script and counting the number of calls to ASSERT. It also returns the number of tests, should you wish to make use of that figure at some point. In 'test' and 'test/ok' mode a warning will be emitted if the actual number of tests does not match the number planned, similar to Test::More. =item only(@test_numbers) Only display the results of these tests =item ignore(@test_numbers) Don't display the results of these tests =item ASSERT($bool, $comment) The workhorse function. Behaviour depends on how the module was imported. $comment is optional. =item ASSESS(@result_strings) Collate the results from a set of tests. In a scalar context returns a result string starting with "ok" or "not ok"; in a list context returns 1=pass or 0=fail, followed by a description. ($bool, $desc) = ASSESS(@args) is equivalent to ($bool, $desc) = INTERPRET(scalar ASSESS(@args)) =item ASSESS_FILE($file, $verbose, $timeout) $verbose is an optional boolean default timeout is 60 seconds (0=never timeout) In a scalar context returns a result string; in a list context returns 1=pass or 0=fail, followed by a description. The timeout uses alarm(), but has no effect on platforms which do not implement alarm(). =item ($bool, $desc) = INTERPRET($result_string) Inteprets a result string. $bool indicates 1=pass/0=fail; $desc is an optional description. =item $bool = EQUAL($item1, $item2) Deep comparison of 2 data structures (i.e. references to some kind of structure) or scalars. =item $bool = EQUALS_FILE($string, $filename) Compares a string with a canned value in a file. =item $bool = MATCHES_FILE($string, $regexfilename) Compares a value with a regex that is read from a file. The regex has the '^' anchor prepended and the '$' anchor appended, after being read in from the file. Handy if you have random numbers or dates in your output. =item $bool = FILES_EQUAL($filename1, $filename2) Test if 2 files' contents are identical =item $bool = DIED($coderef) Test if the coderef died =item COMPILES($filename, $strict, $scalar_reference) Test if the perl code in $filename compiles OK, like perl -c. If $strict is true, tests with the options -Mstrict -w. In scalar context it returns 1 if the code compiled, 0 otherwise. In list context it returns the same boolean, followed by the output (that is, standard output and standard error B) of the syntax check. If $scalar_reference is supplied and is a scalar reference then the standard output and standard error of the syntax check subprocess will be captured B. Standard error will be put into this scalar - IO::CaptureOutput is loaded on demand to do this - and standard output will be returned as described above. =item $contents = READ_FILE($filename) Reads the specified file and returns the contents. Returns undef if file cannot be read. =item $success = WRITE_FILE($filename, $contents) Writes the given contents to the specified file. Returns undef if file cannot be written. =back =head1 OVERHEAD When Test::Assertions is imported with no arguments, ASSERT is aliased to an empty coderef. If this is still too much runtime overhead for you, you can use a constant to optimise out ASSERT statements at compile time. See the section on runtime testing in L for a discussion of overheads, some examples and some benchmark results. =head1 DEPENDENCIES The following modules are loaded on demand: Carp File::Spec Test::More File::Compare IO::CaptureOutput =head1 RELATED MODULES =over 4 =item L and L Minimal unit testing modules =item L Richer unit testing toolkit compatible with Test and Test::Simple =item L Runtime testing toolkit =back =head1 TODO - Declare ASSERT() with :assertions attribute in versions of perl >= 5.9 so it can be optimised away at runtime. It should be possible to declare the attribute conditionally in a BEGIN block (with eval) for backwards compatibility =head1 SEE ALSO L - A guide to using Test::Assertions =head1 VERSION $Revision: 1.54 $ on $Date: 2006/08/07 10:44:42 $ by $Author: simonf $ =head1 AUTHOR John Alden with additions from Piers Kent and Simon Flack =head1 COPYRIGHT (c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt =cut Test-Assertions-1.054/lib/Test/Assertions/0000755016521500001460000000000010466660313022046 5ustar andrewwtechnical00000000000000Test-Assertions-1.054/lib/Test/Assertions/Manual.pod0000644016521500001460000003177210466660244024004 0ustar andrewwtechnical00000000000000=head1 NAME Test::Assertions::Manual - A guide to using Test::Assertions =head1 DESCRIPTION This is a brief guide to how you can use the Test::Assertions module in your code and test scripts. The C documentation has a comprehensive list of options. =head1 Unit testing To use Test::Assertions for unit testing, import it with the argument "test": use Test::Assertions qw(test); The output of Test::Assertions in test mode is suitable for collation with Test::Harness. Only the ASSERT() and plan() routines can create any output - all the other routines simply return values. =head2 Planning tests Test::Assertions offers a "plan tests" syntax similar to Test::More: plan tests => 42; # Which creates the output: 1..42 If you find having to increment the number at the top of your test script every time you add a test irritating, you can use the automatic, Do What I Mean, form: plan tests; In this case, Test::Assertions will read your code and count the number of ASSERT statements and use this for the expected number of tests. A caveat is that it expects all your ASSERT statements to be executed once only, hence ASSERTs in if and foreach blocks will fool Test::Assertions and you'll have to maintain the count manually in these cases. Furthermore, it uses caller() to get the filename of the code so it may not work if you invoke your program with a relative filename and then change working directory before calling this automatic "plan tests;" form. Test::Assertions offers a couple of additional functions - only() and ignore() to control which tests will be reported. Usage is as follows: ignore(2, 5) if($^O eq 'MsWin32'); only(1..10) unless($^O eq 'MsWin32'); Note that these won't stop the actual test code from being attempted, but the results won't be reported. =head2 Testing things The routines for constructing tests are deliberately ALL CAPS so you can discriminate at a glance between the test and what is being tested. To check something does what expected, use ASSERT: ASSERT(1 == 1); This gives the output: ok 1 An optional 2nd arg may be supplied for a comment to label the test: ASSERT(1 == 1, "an example test"); This gives the output: ok 1 (an example test) In the interest of brevity of documentation, I'll omit the 2nd argument from my examples below. For your real-world tests, labelling the output is strongly recommended so when something fails you know what it is. If you are hopelessly addicted to invoking your tests with an ok() routine, Test::Assertions has a concession for Test::Simple/More junkies: use Test::Assertions qw(test/ok); plan tests => 1; ok(1, "ok() works just like ASSERT()"); =head2 More complex tests with helper routines Most real-world unit tests will need to check data structures returned from an API. The EQUAL() function compares two data structures deeply (a bit like Test::More's eq_array or eq_hash): ASSERT( EQUAL(\@arr, [1,2,3]) ); ASSERT( EQUAL(\%observed, \%expected) ); For routines that return large strings or write to files (e.g. templating), you might want to have your expected output held externally in a file. Test::Assertions provides a few routines to make this easy. EQUALS_FILE compares a string to the contents of a file: ASSERT( EQUALS_FILE($returned, "expected.txt") ); Whereas FILES_EQUAL compares the contents of 2 files: $object_to_test->write_file("observed.txt"); ASSERT( FILES_EQUAL("observed.txt", "expected.txt") ); unlink("observed.txt"); #always clean up so state on 2nd run is same as 1st run If your files contain serialized data structures, e.g. the output of Data::Dumper, you may wish to use do(), or eval() their contents, and use the EQUAL() routine to compare the structures, rather than comparing the serialized forms directly. my $var1 = do('file1.datadump'); my $var2 = do('file2.datadump'); ASSERT( EQUAL($var1, $var2), 'serialized versions matched' ); The MATCHES_FILE routine compares a string with regex that is read from a file, which is most useful if your string contains dates, timestamps, filepaths, or other items which might change from one run of the test to the next, or across different machines: ASSERT( MATCHES_FILE($string_to_examine, "expected.regex.txt") ); Another thing you are likely to want to test is code raising exceptions with die(). The DIED() function confirms if a coderef raises an exception: ASSERT( DIED( sub { $object_to_test->method(@bad_inputs); } )); The DIED routine doesn't clobber $@, so you can use this in your test description: ASSERT( DIED( sub { $object_to_test->method(@bad_inputs); } ), "raises an exception - " . (chomp $@, $@)); Occasionally you'll want to check if a perl script simply compiles. Whilst this is no substitute for writing a proper unit test for the script, sometimes it's useful: ASSERT( COMPILES("somescript.pl") ); An optional second argument forces the code to be compiled under 'strict': ASSERT( COMPILES("somescript.pl", 1) ); (normally you'll have this in your script anyway). =head2 Aggregating other tests together For complex systems you may have a whole tree of unit tests, corresponding to different areas of functionality of the system. For example, there may be a set of tests corresponding to the expression evaluation sublanguage within a templating system. Rather than simply aggregating everything with Test::Harness in one flat list, you may want to aggregate each subtree of related functionality so that the Test::Harness summarisation is across these higher-level units. Test::Assertions provides two functions to aggregate the output of other tests. These work on result strings (starting with "ok" or "not ok"). ASSESS is the lower-level routine working directly on result strings, ASSESS_FILE runs a unit test script and parses the output. In a scalar context they return a summary result string: @results = ('ok 1', 'not ok 2', 'A comment', 'ok 3'); print scalar ASSESS(\@results); would result in something like: not ok (1 errors in 3 tests) This output is of course a suitable input to ASSESS so complex hierarchies may be created. In an array context, they return a boolean value and a description which is suitable for feeding into ASSERT (although ASSERT's $;$ prototype means it will ignore the description) : ASSERT ASSESS_FILE("expr/set_1.t"); ASSERT ASSESS_FILE("expr/set_2.t"); ASSERT ASSESS_FILE("expr/set_3.t"); would generate output such as: ok 1 ok 2 ok 3 Finally Test::Assertions provides a helper routine to interpret result strings: ($bool, $description) = INTERPRET("not ok 4 (test four)"); would result in: $bool = 0; $description = "test four"; which might be useful for writing your own custom collation code. =head1 Using Test::Assertions for run-time checking C programmers often use ASSERT macros to trap runtime "should never happen" errors in their code. You can use Test::Assertions to do this: use Test::Assertions qq(die); $rv = some_function(); ASSERT($rv == 0, "some_function returned a non-zero value"); You can also import Test::Assertions with warn rather than die so that the code continues executing: use constant ASSERTIONS_MODE => $ENV{ENVIRONMENT} eq 'production'? 'warn' : 'die'; use Test::Assertions(ASSERTIONS_MODE); Environment variables provide a nice way of switching compile-time behaviour from outside the process. =head2 Minimising overhead Importing Test::Assertions with no arguments results in ASSERT statements doing nothing, but unlike ASSERT macros in C where the preprocessor filters this out before compilation, there are 2 types of residual overhead: =over 4 =item Runtime overhead When Test::Assertions is imported with no arguments, the ASSERT statement is aliased to an empty sub. There is a small overhead in executing this. In practice, unless you do an ASSERT on every other line, or in a performance-critical loop, you're unlikely to notice the overhead compared to the other work that your code is doing. =item Compilation overhead The Test::Assertions module must be compiled even when it is imported with no arguments. Test::Assertions loads its helper modules on demand and avoids using pragmas to minimise its compilation overhead. Currently Test::Assertions does not go to more extreme measures to cut its compilation overhead in the interests of maintainability and ease of installation. =back Both can be minimised by using a constant: use constant ENABLE_ASSERTIONS => $ENV{ENABLE_ASSERTIONS}; #Minimise compile-time overhead if(ENABLE_ASSERTIONS) { require Test::Assertions; import Test::Assertions qq(die); } $rv = some_function(); #Eliminate runtime overhead ASSERT($rv == 0, "some_function returned a non-zero value") if(ENABLE_ASSERTIONS); Unlike Carp::Assert, Test::Assertions does not come with a "built-in" constant (DEBUG in the case of Carp::Assert). Define your own constant, attach it to your own compile-time logic (e.g. env vars) and call it whatever you like. =head2 How expensive is a null ASSERT? Here's an indication of the overhead of calling ASSERT when Test::Assertions is imported with no arguments. A comparison is included with Carp::Assert just to show that it's in the same ballpark - we are not advocating one module over the other. As outlined above, using a constant to disable assertions is recommended in performance-critical code. #!/usr/local/bin/perl use Benchmark; use Test::Assertions; use Carp::Assert; use constant ENABLE_ASSERTIONS => 0; #Compare null ASSERT to simple linear algebra statement timethis(1e6, sub{ ASSERT(1); #Test::Assertions }); timethis(1e6, sub{ assert(1); #Carp::Assert }); timethis(1e6, sub{ ASSERT(1) if ENABLE_ASSERTIONS; }); timethis(1e6, sub{ $x=$x*2 + 3; }); Results on Sun E250 (with 2x400Mhz CPUs) running perl 5.6.1 on solaris 9: Test::Assertions: timethis 1000000: 3 wallclock secs ( 3.88 usr + 0.00 sys = 3.88 CPU) @ 257731.96/s (n=1000000) Carp::Assert: timethis 1000000: 6 wallclock secs ( 6.08 usr + 0.00 sys = 6.08 CPU) @ 164473.68/s (n=1000000) Test::Assertions + const: timethis 1000000: -1 wallclock secs ( 0.07 usr + 0.00 sys = 0.07 CPU) @ 14285714.29/s (n=1000000) (warning: too few iterations for a reliable count) some algebra: timethis 1000000: 1 wallclock secs ( 2.50 usr + 0.00 sys = 2.50 CPU) @ 400000.00/s (n=1000000) Results for 1.7Ghz pentium M running activestate perl 5.6.1 on win XP: Test::Assertions: timethis 1000000: 0 wallclock secs ( 0.42 usr + 0.00 sys = 0.42 CPU) @ 2380952.38/s (n=1000000) Carp::Assert: timethis 1000000: 0 wallclock secs ( 0.57 usr + 0.00 sys = 0.57 CPU) @ 1751313.49/s (n=1000000) Test::Assertions + const: timethis 1000000: -1 wallclock secs (-0.02 usr + 0.00 sys = -0.02 CPU) @ -50000000.00/s (n=1000000) (warning: too few iterations for a reliable count) some algebra: timethis 1000000: 0 wallclock secs ( 0.50 usr + 0.00 sys = 0.50 CPU) @ 1996007.98/s (n=1000000) =head2 How significant is the compile-time overhead? Here's an indication of the compile-time overhead for Test::Assertions v1.050 and Carp::Assert v0.18. The cost of running import() is also included. #!/usr/local/bin/perl use Benchmark; use lib qw(../lib); timethis(3e2, sub { require Test::Assertions; delete $INC{"Test/Assertions.pm"}; }); timethis(3e2, sub { require Test::Assertions; import Test::Assertions; delete $INC{"Test/Assertions.pm"}; }); timethis(3e2, sub { require Carp::Assert; delete $INC{"Carp/Assert.pm"}; }); timethis(3e2, sub { require Carp::Assert; import Carp::Assert; delete $INC{"Carp/Assert.pm"}; }); Results on Sun E250 (with 2x400Mhz CPUs) running perl 5.6.1 on solaris 9: Test::Assertions: timethis 300: 6 wallclock secs ( 6.19 usr + 0.10 sys = 6.29 CPU) @ 47.69/s (n=300) Test::Assertions + import: timethis 300: 7 wallclock secs ( 6.56 usr + 0.03 sys = 6.59 CPU) @ 45.52/s (n=300) Carp::Assert: timethis 300: 3 wallclock secs ( 2.47 usr + 0.32 sys = 2.79 CPU) @ 107.53/s (n=300) Carp::Assert + import: timethis 300: 41 wallclock secs (40.58 usr + 0.32 sys = 40.90 CPU) @ 7.33/s (n=300) Results for 1.7Ghz pentium M running activestate perl 5.6.1 on win XP: Test::Assertions: timethis 300: 2 wallclock secs ( 1.45 usr + 0.21 sys = 1.66 CPU) @ 180.51/s (n=300) Test::Assertions + import: timethis 300: 2 wallclock secs ( 1.58 usr + 0.29 sys = 1.87 CPU) @ 160.26/s (n=300) Carp::Assert: timethis 300: 1 wallclock secs ( 0.99 usr + 0.26 sys = 1.25 CPU) @ 239.62/s (n=300) Carp::Assert + import: timethis 300: 6 wallclock secs ( 5.42 usr + 0.38 sys = 5.80 CPU) @ 51.74/s (n=300) If using a constant to control compilation is not to your liking, you may want to experiment with SelfLoader or AutoLoader to cut down the compilation overhead further by delaying compilation of some of the subroutines in Test::Assertions (see L and L for more information) until the first time they are used. =head1 VERSION $Revision: 1.10 $ on $Date: 2005/05/04 15:56:39 $ =head1 AUTHOR John Alden =cut Test-Assertions-1.054/lib/Test/Assertions/TestScript.pm0000644016521500001460000001070410466660244024515 0ustar andrewwtechnical00000000000000package Test::Assertions::TestScript; use strict; use Getopt::Long qw(:config pass_through bundling); use Log::Trace; use Test::Assertions qw( test );; use File::Basename; use vars qw( $VERSION $SAVE_OUTPUT $TRACE $TRACE_DEEP @TRACE_MODULE ); $VERSION = sprintf"%d.%03d", q$Revision: 1.18 $ =~ /: (\d+)\.(\d+)/; sub import { my $package = shift; my %options = @_; if ($0) { my $t_directory = dirname ( $0 ); chdir ( $t_directory ) or die "Could not chdir to unit test directory '$t_directory'\n"; } else { # this should never happen die "Could not find script location\n"; } unshift @INC, "./lib", "../lib"; my $additional_options = $options{options} || {}; GetOptions( 't' => \$TRACE, 'T' => \$TRACE_DEEP, 's' => \$SAVE_OUTPUT, 'trace-module=s@' => \@TRACE_MODULE, %$additional_options ); plan tests => $options{tests}; { package main; # Cheating to import into the right place import Test::Assertions qw( test ); } } INIT { package main; # Cheating to import into the right place import Log::Trace unless ($Test::Assertions::TestScript::TRACE || $Test::Assertions::TestScript::TRACE_DEEP); # still import the stubs import Log::Trace 'print' => { Deep => 0 } if $Test::Assertions::TestScript::TRACE; import Log::Trace 'print' => { Deep => 1 } if $Test::Assertions::TestScript::TRACE_DEEP; foreach (@Test::Assertions::TestScript::TRACE_MODULE) { eval "require $_"; import Log::Trace print => {Match => $_, Deep => 1}; } } 1; =head1 NAME Test::Assertions::TestScript - Base for test scripts =head1 SYNOPSIS use Test::Assertions::TestScript; use Module::To::Test qw( frobnicate ); ASSERT(frobnicate(),"Frobnicate returns true"); =head1 DESCRIPTION Test::Assertions::TestScript provides a base for writing test scripts. It performs some common actions such as setting up the @INC path and parsing command-line options, specifically: =over =item * The lib and t/lib directories are added to @INC. =item * The current directory is changed to the directory the script is in. =item * Test script command-line options are parsed. (See L) =item * The test set of functions from Test::Assertions are imported into your test script. =back Test::Assertions::TestScript makes certain assumptions about the filesystem layout of your project: =over 4 =item * Modules that you are testing are in the lib directory of your project. =item * Test scripts are in the t directory. =item * There may also be a t/lib directory for any modules written for the test process. =back Test::Assertions::TestScript should be Cd B any modules that you intend to test. =head1 OPTIONS Options can be supplied to the import function. These should be placed after the C or C. For example use Test::Assertions::TestScript( tests => 10, options => { 'b', \$opt_b }) The following options are defined: =over =item tests The number of tests to pass to C from Test::Assertions. For example to tell Test::Assertions::TestScript that the script contains 42 tests: use Test::Assertions::TestScript tests => 42; =item options A hashref of additional options to capture via Getopt::Long. The "options" import parameter is passed verbatim to GetOptions, so something along the following lines is required in order to capture the "-b" command line option: use Test::Assertions::TestScript( options => { 'b' => \$opt_b } ); =back =head1 COMMAND-LINE OPTIONS A script based on Test::Assertions::TestScript will detect the following command line options. =over =item -t Shallow tracing. Traces are Ced and AutoImport is turned on. =item -T Deep tracing. Traces are Ced and AutoImport is turned on. =item --trace-module=MODULE Imports tracing into MODULE specifically. Can be specified multiple times. =item -s Save generated output. You will need to write the actual code to do this in your testscript, but you can inspect $Test::Assertions::TestScript::SAVE_OUTPUT to see whether this argument was given. =back Be aware that all other command line options will be disregarded unless the C import parameter is used to capture them. =head1 VERSION $Revision: 1.18 $ =head1 AUTHOR Colin Robertson =head1 COPYRIGHT (c) BBC 2005-6. This program is free software; you can redistribute it and/or modify it under the GNU GPL. See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt =cut Test-Assertions-1.054/COPYING0000644016521500001460000004313110466660244017267 0ustar andrewwtechnical00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. Test-Assertions-1.054/Changes0000644016521500001460000000036510466660244017531 0ustar andrewwtechnical00000000000000Thu Aug 10 16:28:26 2006 - 1.054 Don't count ASSERT() statements that appear on commented-out lines. Added Test::Assertions::TestScript Version 1.050 - 2005-05-06 Optimised compile-time overhead and added extra docs on runtime testing Test-Assertions-1.054/MANIFEST0000644016521500001460000000052210466660272017363 0ustar andrewwtechnical00000000000000Changes COPYING Makefile.PL MANIFEST MANIFEST.SKIP README lib/Test/Assertions.pm lib/Test/Assertions/TestScript.pm lib/Test/Assertions/Manual.pod t/Test-Assertions.t t/Test-Assertion_style.pl t/Test-Assertions-TestScript.t t/pod_coverage.t t/fails.pl t/pod.t META.yml Module meta-data (added by MakeMaker) Test-Assertions-1.054/MANIFEST.SKIP0000644016521500001460000000017310466660244020131 0ustar andrewwtechnical00000000000000^blib ^bak ~$ (?:^|/)[Mm]akefile(?:\.old)?$ (?:^|/)pm_to_blib$ ^Test-Assertions-\d+\.\d+\.(zip|tar\.gz|tgz)$ [Cc][Vv][Ss]/ Test-Assertions-1.054/META.yml0000644016521500001460000000065210466660312017502 0ustar andrewwtechnical00000000000000# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Test-Assertions version: 1.054 version_from: lib/Test/Assertions.pm installdirs: site requires: Carp: 0 Getopt::Long: 0 Log::Trace: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Test-Assertions-1.054/README0000644016521500001460000000104210466660247017112 0ustar andrewwtechnical00000000000000Test::Assertions v1.054 (c) BBC 2004, 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt QUICK START: Install Test::Assertions by unpacking the tarball and running the following commands in the source directory: perl Makefile.PL make make test make install Then delete the source directory tree since it's no longer needed. run 'perldoc Test::Assertions' to read the full documentation. Test-Assertions-1.054/Makefile.PL0000644016521500001460000000073710466660244020213 0ustar andrewwtechnical00000000000000use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Test::Assertions', VERSION_FROM => 'lib/Test/Assertions.pm', PREREQ_PM => { Carp => 0, Log::Trace => 0, Getopt::Long => 0, }, ABSTRACT_FROM => 'lib/Test/Assertions.pm', AUTHOR => 'British Broadcasting Corporation', );