|
From: <jgr...@us...> - 2003-07-26 18:28:30
|
Update of /cvsroot/popfile/engine
In directory sc8-pr-cvs1:/tmp/cvs-serv15772
Modified Files:
coverage.pl tests.pl
Log Message:
Remove all tabs from the source code and fix my editor so that *I* don't introduce any more
Index: coverage.pl
===================================================================
RCS file: /cvsroot/popfile/engine/coverage.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** coverage.pl 26 Jul 2003 17:41:26 -0000 1.8
--- coverage.pl 26 Jul 2003 18:28:27 -0000 1.9
***************
*** 43,54 ****
$current_line += 1;
! my $state = <LINE_DATA>;
if ( $state =~ /1/ ) {
$count{$module}{executed}{$current_line} = 1;
} elsif ( $state =~ /0/ ) {
! if ( $count{$module}{executed}{$current_line} != 1 ) {
$count{$module}{executed}{$current_line} = 0;
! }
}
}
--- 43,54 ----
$current_line += 1;
! my $state = <LINE_DATA>;
if ( $state =~ /1/ ) {
$count{$module}{executed}{$current_line} = 1;
} elsif ( $state =~ /0/ ) {
! if ( $count{$module}{executed}{$current_line} != 1 ) {
$count{$module}{executed}{$current_line} = 0;
! }
}
}
***************
*** 68,72 ****
if ($count{$module}{executed}{$line} == 1) {
$total_executed += 1;
! } else {
$total_not_executed += 1;
}
--- 68,72 ----
if ($count{$module}{executed}{$line} == 1) {
$total_executed += 1;
! } else {
$total_not_executed += 1;
}
***************
*** 111,115 ****
print HTML " ";
$length -= 1;
! }
print HTML "$line </font>";
print HTML "<span style=\"background: $block\"> </span><font color=$color>$_</font>";
--- 111,115 ----
print HTML " ";
$length -= 1;
! }
print HTML "$line </font>";
print HTML "<span style=\"background: $block\"> </span><font color=$color>$_</font>";
Index: tests.pl
===================================================================
RCS file: /cvsroot/popfile/engine/tests.pl,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** tests.pl 21 Jul 2003 19:03:51 -0000 1.22
--- tests.pl 26 Jul 2003 18:28:27 -0000 1.23
***************
*** 23,33 ****
# ---------------------------------------------------------------------------------------------
#
! # test_report - Report whether a test passed or not
#
# $ok Boolean indicating whether the test passed
! # $test String containing the test executed
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $context (Optional) String containing extra context information
#
# ---------------------------------------------------------------------------------------------
--- 23,33 ----
# ---------------------------------------------------------------------------------------------
#
! # test_report - Report whether a test passed or not
#
# $ok Boolean indicating whether the test passed
! # $test String containing the test executed
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $context (Optional) String containing extra context information
#
# ---------------------------------------------------------------------------------------------
***************
*** 35,63 ****
sub test_report
{
! my ( $ok, $test, $file, $line, $context ) = @_;
!
! $test_count += 1;
!
! if ( !$ok ) {
! $fail_messages .= "\n $file:$line failed '$test'";
! if ( defined( $context ) ) {
! $fail_messages .= " ($context)";
! }
! $test_failures += 1;
! } else {
# print "Test pass at $file:$line\n";
}
!
! flush STDOUT;
}
# ---------------------------------------------------------------------------------------------
#
! # test_assert - Perform a test and assert that its result must be true
#
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $test String containing the test to be executed
! # $context (Optional) String containing extra context information
#
# Example: test_assert( 'function(parameter) == 1' ) YOU DO NOT NEED TO GIVE THE
--- 35,63 ----
sub test_report
{
! my ( $ok, $test, $file, $line, $context ) = @_;
!
! $test_count += 1;
!
! if ( !$ok ) {
! $fail_messages .= "\n $file:$line failed '$test'";
! if ( defined( $context ) ) {
! $fail_messages .= " ($context)";
! }
! $test_failures += 1;
! } else {
# print "Test pass at $file:$line\n";
}
!
! flush STDOUT;
}
# ---------------------------------------------------------------------------------------------
#
! # test_assert - Perform a test and assert that its result must be true
#
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $test String containing the test to be executed
! # $context (Optional) String containing extra context information
#
# Example: test_assert( 'function(parameter) == 1' ) YOU DO NOT NEED TO GIVE THE
***************
*** 68,85 ****
sub test_assert
{
! my ( $file, $line, $test, $context ) = @_;
!
! test_report( eval( $test ), $test, $file, $line, $context );
}
# ---------------------------------------------------------------------------------------------
#
! # test_assert_equal - Perform a test and assert that its result is equal an expected result
#
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $test The result of the test that was just run
! # $expected The expected result
! # $context (Optional) String containing extra context information
#
# Example: test_assert_equal( function(parameter), 'result' )
--- 68,85 ----
sub test_assert
{
! my ( $file, $line, $test, $context ) = @_;
!
! test_report( eval( $test ), $test, $file, $line, $context );
}
# ---------------------------------------------------------------------------------------------
#
! # test_assert_equal - Perform a test and assert that its result is equal an expected result
#
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $test The result of the test that was just run
! # $expected The expected result
! # $context (Optional) String containing extra context information
#
# Example: test_assert_equal( function(parameter), 'result' )
***************
*** 92,120 ****
sub test_assert_equal
{
! my ( $file, $line, $test, $expected, $context ) = @_;
! my $result;
! if ( !( $expected =~ /[^0-9]/ ) ) {
!
! # This int() and is so that we don't get bitten by odd
! # floating point problems
! my $scale = 1e10;
! $result = ( int( $test * $scale ) == int( $expected * $scale ) );
! } else {
! $result = ( $test eq $expected );
! }
! test_report( $result, "expecting $expected and got $test", $file, $line, $context );
}
# ---------------------------------------------------------------------------------------------
#
! # test_assert_regexp - Perform a test and assert that its result matches a regexp
#
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $test The result of the test that was just run
! # $expected The expected result in the form of a regexp
! # $context (Optional) String containing extra context information
#
# Example: test_assert_regexp( function(parameter), '^result' )
--- 92,120 ----
sub test_assert_equal
{
! my ( $file, $line, $test, $expected, $context ) = @_;
! my $result;
! if ( !( $expected =~ /[^0-9]/ ) ) {
!
! # This int() and is so that we don't get bitten by odd
! # floating point problems
! my $scale = 1e10;
! $result = ( int( $test * $scale ) == int( $expected * $scale ) );
! } else {
! $result = ( $test eq $expected );
! }
! test_report( $result, "expecting $expected and got $test", $file, $line, $context );
}
# ---------------------------------------------------------------------------------------------
#
! # test_assert_regexp - Perform a test and assert that its result matches a regexp
#
! # $file The name of the file invoking the test
! # $line The line in the $file where the test can be found
! # $test The result of the test that was just run
! # $expected The expected result in the form of a regexp
! # $context (Optional) String containing extra context information
#
# Example: test_assert_regexp( function(parameter), '^result' )
***************
*** 151,188 ****
if ( $test =~ /$pattern/ ) {
! # This works by reading the entire suite into the $suite variable
! # and then changing calls to test_assert_equal so that they include
! # the line number and the file they are from, then the $suite is
! # evaluated
! my $current_test_count = $test_count;
! my $current_error_count = $test_failures;
!
! print "\nRunning $test... ";
! flush STDOUT;
! $fail_messages = '';
! my $suite;
! my $ln = 0;
! open SUITE, "<$test";
! while (<SUITE>) {
! my $line = $_;
! $ln += 1;
! $line =~ s/(test_assert_regexp\()/$1 '$test', $ln,/g;
! $line =~ s/(test_assert_equal\()/$1 '$test', $ln,/g;
! $line =~ s/(test_assert\()/$1 '$test', $ln,/g;
! $suite .= $line;
! }
! close SUITE;
! if ( !defined( eval $suite ) ) {
print "Error in $test: $@";
$code = 1;
! }
!
! if ( $test_failures > $current_error_count ) {
! print "failed (" . ( $test_count - $current_test_count ) . " ok, " . ( $test_failures - $current_error_count ) . " failed)\n";
! print $fail_messages . "\n";
$code = 1;
! } else {
! print "ok (" . ( $test_count - $current_test_count ) . " ok)";
! }
}
}
--- 151,188 ----
if ( $test =~ /$pattern/ ) {
! # This works by reading the entire suite into the $suite variable
! # and then changing calls to test_assert_equal so that they include
! # the line number and the file they are from, then the $suite is
! # evaluated
! my $current_test_count = $test_count;
! my $current_error_count = $test_failures;
!
! print "\nRunning $test... ";
! flush STDOUT;
! $fail_messages = '';
! my $suite;
! my $ln = 0;
! open SUITE, "<$test";
! while (<SUITE>) {
! my $line = $_;
! $ln += 1;
! $line =~ s/(test_assert_regexp\()/$1 '$test', $ln,/g;
! $line =~ s/(test_assert_equal\()/$1 '$test', $ln,/g;
! $line =~ s/(test_assert\()/$1 '$test', $ln,/g;
! $suite .= $line;
! }
! close SUITE;
! if ( !defined( eval $suite ) ) {
print "Error in $test: $@";
$code = 1;
! }
!
! if ( $test_failures > $current_error_count ) {
! print "failed (" . ( $test_count - $current_test_count ) . " ok, " . ( $test_failures - $current_error_count ) . " failed)\n";
! print $fail_messages . "\n";
$code = 1;
! } else {
! print "ok (" . ( $test_count - $current_test_count ) . " ok)";
! }
}
}
|