r50815 - in /branches/upstream/libtest-longstring-perl/current: Changes MANIFEST MANIFEST.SKIP META.yml Makefile.PL lib/Test/LongString.pm t/04contains.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Tue Jan 12 18:08:58 UTC 2010


Author: jawnsy-guest
Date: Tue Jan 12 18:08:39 2010
New Revision: 50815

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50815
Log:
[svn-upgrade] Integrating new upstream version, libtest-longstring-perl (0.12)

Added:
    branches/upstream/libtest-longstring-perl/current/MANIFEST.SKIP
Modified:
    branches/upstream/libtest-longstring-perl/current/Changes
    branches/upstream/libtest-longstring-perl/current/MANIFEST
    branches/upstream/libtest-longstring-perl/current/META.yml
    branches/upstream/libtest-longstring-perl/current/Makefile.PL
    branches/upstream/libtest-longstring-perl/current/lib/Test/LongString.pm
    branches/upstream/libtest-longstring-perl/current/t/04contains.t

Modified: branches/upstream/libtest-longstring-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/Changes?rev=50815&op=diff
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/Changes (original)
+++ branches/upstream/libtest-longstring-perl/current/Changes Tue Jan 12 18:08:39 2010
@@ -11,3 +11,7 @@
 0.11
     Require a more recent Test::Builder::Tester,
     since tests fail with 1.03.
+
+0.12
+    Show longest common substring in diagnostics
+    (Breno G. de Oliveira)

Modified: branches/upstream/libtest-longstring-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/MANIFEST?rev=50815&op=diff
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/MANIFEST (original)
+++ branches/upstream/libtest-longstring-perl/current/MANIFEST Tue Jan 12 18:08:39 2010
@@ -1,6 +1,7 @@
 lib/Test/LongString.pm
 Makefile.PL
 MANIFEST
+MANIFEST.SKIP
 README
 t/01teststring.t
 t/02import.t

Added: branches/upstream/libtest-longstring-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/MANIFEST.SKIP?rev=50815&op=file
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libtest-longstring-perl/current/MANIFEST.SKIP Tue Jan 12 18:08:39 2010
@@ -1,0 +1,16 @@
+# Avoid version control files.
+\B\.svn\b
+\B\.git\b
+
+# Avoid Makemaker generated and utility files.
+^MANIFEST\.bak
+^Makefile$
+^blib/
+^MakeMaker-\d
+^pm_to_blib$
+
+# Avoid temp and backup files.
+~$
+\.old$
+\#$
+^\.#

Modified: branches/upstream/libtest-longstring-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/META.yml?rev=50815&op=diff
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/META.yml (original)
+++ branches/upstream/libtest-longstring-perl/current/META.yml Tue Jan 12 18:08:39 2010
@@ -1,12 +1,15 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Test-LongString
-version:      0.11
-version_from: lib/Test/LongString.pm
-installdirs:  site
-requires:
+--- #YAML:1.0
+name:                Test-LongString
+version:             0.12
+abstract:            ~
+license:             perl
+author:              
+    - Rafael Garcia-Suarez <rgs at consttype.org>
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
     Test::Builder:                 0.12
     Test::Builder::Tester:         1.04
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30_01
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: branches/upstream/libtest-longstring-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/Makefile.PL?rev=50815&op=diff
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/Makefile.PL (original)
+++ branches/upstream/libtest-longstring-perl/current/Makefile.PL Tue Jan 12 18:08:39 2010
@@ -1,10 +1,12 @@
 use ExtUtils::MakeMaker;
 
 WriteMakefile(
+    AUTHOR	    => 'Rafael Garcia-Suarez <rgs at consttype.org>',
     NAME	    => "Test::LongString",
     VERSION_FROM    => "lib/Test/LongString.pm",
     PREREQ_PM	    => {
 	'Test::Builder'		=> 0.12,
 	'Test::Builder::Tester'	=> 1.04,
     },
+    LICENSE	    => 'perl',
 );

Modified: branches/upstream/libtest-longstring-perl/current/lib/Test/LongString.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/lib/Test/LongString.pm?rev=50815&op=diff
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/lib/Test/LongString.pm (original)
+++ branches/upstream/libtest-longstring-perl/current/lib/Test/LongString.pm Tue Jan 12 18:08:39 2010
@@ -3,7 +3,7 @@
 use strict;
 use vars qw($VERSION @ISA @EXPORT $Max $Context);
 
-$VERSION = '0.11';
+$VERSION = '0.12';
 
 use Test::Builder;
 my $Tester = new Test::Builder();
@@ -75,14 +75,67 @@
         $Tester->ok($ok, $name);
         if (!$ok) {
             my ($g, $e) = (_display($str), _display($sub));
+
+            # if _lcss() returned the actual substring,
+            # all we'd have to do is:
+            # my $l = _display( _lcss($str, $sub) );
+
+            my ($off, $len) = _lcss($str, $sub);
+            my $l = _display( substr($str, $off, $len) );
+
             $Tester->diag(<<DIAG);
     searched: $g
   can't find: $e
-DIAG
+        LCSS: $l
+DIAG
+
+            # if there's room left, show some surrounding context
+            if ($len < $Max) {
+                my $available = int( ($Max - $len) / 2 );
+                my $begin = ($off - ($available*2) > 0) ? $off - ($available*2) 
+                          : ($off - $available > 0) ? $off - $available : 0;
+                my $c = _display( substr($str, $begin, $Max) );
+
+                $Tester->diag("LCSS context: $c");
+            }
         }
     }
     return $ok;
 }
+
+sub _lcss($$) {
+    my ($S, $T) = (@_);
+    my @L;
+    my ($offset, $length) = (0,0);
+
+    # prevent us from having to zero a $ix$j matrix
+    no warnings 'uninitialized';
+
+    # now the actual LCSS algorithm
+    foreach my $i (0 .. length($S) ) {
+        foreach my $j (0 .. length($T)) {
+            if (substr($S, $i, 1) eq substr($T, $j, 1)) {
+                if ($i == 0 or $j == 0) {
+                    $L[$i][$j] = 1;
+                }
+                else {
+                    $L[$i][$j] = $L[$i-1][$j-1] + 1;
+                }
+                if ($L[$i][$j] > $length) {
+                    $length = $L[$i][$j];
+                    $offset = $i - $length + 1;
+                }
+            }
+        }
+    }
+
+    # if you want to display just the lcss:
+    # return substr($S, $offset, $length);
+
+    # but to display the surroundings, we need to:
+    return ($offset, $length);
+}
+
 
 sub lacks_string($$;$) {
     my ($str,$sub,$name) = @_;
@@ -358,6 +411,10 @@
 This program is free software; you may redistribute it and/or modify it under
 the same terms as Perl itself.
 
+A git repository for this module is available at
+
+    http://consttype.org/git/Test-LongString.git
+
 =head1 SEE ALSO
 
 L<Test::Builder>, L<Test::Builder::Tester>, L<Test::More>.

Modified: branches/upstream/libtest-longstring-perl/current/t/04contains.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-longstring-perl/current/t/04contains.t?rev=50815&op=diff
==============================================================================
--- branches/upstream/libtest-longstring-perl/current/t/04contains.t (original)
+++ branches/upstream/libtest-longstring-perl/current/t/04contains.t Tue Jan 12 18:08:39 2010
@@ -14,11 +14,13 @@
 
 # Not in there
 test_out("not ok 1 - Any nachos?");
-test_fail(3);
+test_fail(5);
 test_diag(qq(    searched: "Dog food"));
 test_diag(qq(  can't find: "Nachos"));
+test_diag(qq(        LCSS: "o"));
+test_diag(qq(LCSS context: "Dog food"));
 contains_string("Dog food","Nachos", "Any nachos?");
-test_test("Substring doesn't match");
+test_test("Substring doesn't match (with LCS)");
 
 # Source string undef
 test_out("not ok 1 - Look inside undef");
@@ -33,3 +35,5 @@
 test_diag(qq(String to look for is undef));
 contains_string('"Mesh" is not a color', undef, "Look for undef");
 test_test("Substring undef fails");
+
+




More information about the Pkg-perl-cvs-commits mailing list