[MKDoc-commit] [Petal] forgot tests for passing arguments to coderefs

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Fri Jun 16 15:12:16 BST 2006


Log Message:
-----------
[Petal] forgot tests for passing arguments to coderefs

Added Files:
-----------
    Petal/t:
        098_multiple-attributes.t
    Petal/t/data:
        multiple-attributes.xml

-------------- next part --------------
--- /dev/null
+++ t/098_multiple-attributes.t
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+package thing;
+
+sub new
+{
+    my $class = shift;
+    $class = ref $class || $class;
+    my $self = bless {}, $class;
+    return $self;
+}
+
+sub method
+{
+   my $self = shift;
+   join ':', @_;
+}
+
+package main;
+
+use warnings;
+use strict;
+use lib ('lib');
+use Test::More 'no_plan';
+use Petal;
+
+$|=1;
+
+$Petal::BASE_DIR     = './t/data/';
+$Petal::DISK_CACHE   = 0;
+$Petal::MEMORY_CACHE = 0;
+$Petal::TAINT        = 1;
+
+my $template_file = 'multiple-attributes.xml';
+my $template      = new Petal ($template_file);
+
+sub joinme {join ':', @_}
+my $object = new thing;
+my %hash = ( foo => 'bar' );
+
+my $string        = $template->process (object => $object, coderef => \&joinme, hash => \%hash);
+
+like ($string, '/harpo:chico/');
+like ($string, '/groucho:zeppo/');
+
+__END__
--- /dev/null
+++ t/data/multiple-attributes.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<xml xmlns:petal="http://purl.org/petal/1.0/">
+  <foo petal:content="coderef --harpo --chico">Some stuff</foo>
+  <foo petal:content="object/method --groucho --zeppo">Some other stuff</foo>
+</xml>


More information about the MKDoc-commit mailing list