added count
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 30 Jan 2007 18:21:17 +0000 (18:21 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 30 Jan 2007 18:21:17 +0000 (18:21 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@791 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Normalize.pm
t/3-normalize.t

index 2eedc07..69dac72 100644 (file)
@@ -21,6 +21,7 @@ use Exporter 'import';
        split_rec_on
 
        get set
+       count
 /;
 
 use warnings;
@@ -41,11 +42,11 @@ WebPAC::Normalize - describe normalisaton rules using sets
 
 =head1 VERSION
 
-Version 0.25
+Version 0.26
 
 =cut
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 =head1 SYNOPSIS
 
@@ -1289,6 +1290,18 @@ sub get {
        return $v;
 }
 
+=head2 count
+
+  if ( count( @result ) == 1 ) {
+       # do something if only 1 result is there
+  }
+
+=cut
+
+sub count {
+       warn "## count ",dump(@_),$/;
+       return @_ . '';
+}
 
 # END
 1;
index 7a0826a..6dcc3b3 100755 (executable)
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 311;
+use Test::More tests => 322;
 use Test::Exception;
 use Cwd qw/abs_path/;
 use blib;
@@ -194,6 +194,13 @@ sub test_s {
        cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix');
        cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround');
 
+       # count
+       my @el;
+       for my $i ( 0 .. 10 ) {
+               cmp_ok( count( @el ), '==', $i, "count($i)");
+               push @el, "element $i";
+       }
+
        # lookups
 
        throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()';