Shlomi Fish avatar Shlomi Fish committed 746802d

Convert match_file to Counter.

Comments (0)

Files changed (1)

t/27new_callbacks_simple.t

 use strict;
 use warnings;
 
+use lib './t/lib';
+
+use Counter;
 # $Id$
 
 # Should be 20.
 
 my $icb    = XML::LibXML::InputCallback->new();
 # TEST
-
 ok($icb, ' TODO : Add test name');
 
-$icb->register_callbacks( [ \&match_file, \&open_file, 
+my $match_file_counter = Counter->new(
+    {
+        gen_cb => sub {
+            my $inc_cb = shift;
+
+            sub {
+                my $uri = shift;
+                if ( $uri =~ /^\/example\// ){
+                    $inc_cb->();
+                    return 1;
+                }
+                return 0;     
+            }
+        }
+    }
+);
+
+$icb->register_callbacks( [ $match_file_counter->cb(), \&open_file, 
                             \&read_file, \&close_file ] );
 
 my $parser = XML::LibXML->new();
 my $doc = $parser->parse_string($string);
 
 # TEST
+$match_file_counter->test(1, 'match_file matched once.');
+
+# TEST
 
 ok($doc, ' TODO : Add test name');
 # TEST
 # --------------------------------------------------------------------- #
 # callback set 1 (perl file reader)
 # --------------------------------------------------------------------- #
-sub match_file {
-        my $uri = shift;
-        if ( $uri =~ /^\/example\// ){
-                # TEST
-                ok(1, 'match_file');
-                return 1;
-        }
-        return 0;        
-}
 
 sub open_file {
         my $uri = shift;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.