Commits

Shlomi Fish committed b6ef2a8

More Stackering.

Comments (0)

Files changed (1)

 use Counter;
 use Stacker;
 
-# should be 51.
-use Test::More tests => 51;
+# should be 49.
+use Test::More tests => 49;
 
 # BEGIN { plan tests => 55 }
 
     }
 );
 
-my $SAXNSTester_start_prefix_mapping_stacker = Stacker->new(
-    {
-        gen_cb => sub {
-            my $push_cb = shift;
-            return sub {
-                my $node = shift;
 
-                $push_cb->(
-                    ($node->{NamespaceURI} =~ /\A(?:urn:camels|urn:mammals|urn:a)\z/)
-                    ? 'true'
-                    : 'false'
-                );
+sub _create_urn_stacker
+{
+    return
+    Stacker->new(
+        {
+            gen_cb => sub {
+                my $push_cb = shift;
+                return sub {
+                    my $node = shift;
 
-                return;
-            };
-        },
-    }
-);
+                    $push_cb->(
+                        ($node->{NamespaceURI} =~ /\A(?:urn:camels|urn:mammals|urn:a)\z/)
+                        ? 'true'
+                        : 'false'
+                    );
+
+                    return;
+                };
+            },
+        }
+    );
+}
+
+my $SAXNSTester_start_prefix_mapping_stacker = _create_urn_stacker();
+my $SAXNSTester_end_prefix_mapping_stacker = _create_urn_stacker();
 
 # TEST
 ok(XML::SAX->add_parser(q(XML::LibXML::SAX::Parser)), 'add_parser is successful.');
         ],
         'Three successful SAXNSTester start_prefix_mapping.',
     );
+    # TEST
+    $SAXNSTester_end_prefix_mapping_stacker->test(
+        [
+            qw(true true true)
+        ],
+        'Three successful SAXNSTester end_prefix_mapping.',
+    );
 }
 
 ########### Namespace test ( empty namespaces ) ########
 
 sub end_prefix_mapping {
     my ($self, $node) = @_;
-    # warn("end_prefix_mapping:\n", Dumper($node));
-    # TEST*3
-    like($node->{NamespaceURI}, qr/\A(?:urn:camels|urn:mammals|urn:a)\z/, 
-        'SAXNSTester::end_prefix_mapping'
-    );
+
+    $SAXNSTester_end_prefix_mapping_stacker->cb()->($node);
+
+    return;
 }
 
 1;
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.