[MKDoc-commit] [Petal] tests showing breakage when using cache and
multi-language
bruno at mkdoc.demon.co.uk
bruno at mkdoc.demon.co.uk
Thu Mar 10 17:44:36 GMT 2005
Log Message:
-----------
[Petal] tests showing breakage when using cache and multi-language includes
Modified Files:
--------------
Petal:
Changes
MANIFEST
Added Files:
-----------
Petal/t:
085_lang_include_memcache.t
086_lang_include_diskcache.t
-------------- next part --------------
Index: MANIFEST
===================================================================
RCS file: /var/spool/cvs/Petal/MANIFEST,v
retrieving revision 1.48
retrieving revision 1.49
diff -LMANIFEST -LMANIFEST -u -r1.48 -r1.49
--- MANIFEST
+++ MANIFEST
@@ -89,6 +89,8 @@
t/082_Petal_Gettext.t
t/083_test_attributes_chars.t
t/084_Cookbook.t
+t/085_lang_include_memcache.t
+t/086_lang_include_diskcache.t
t/benchmark.pl
t/data/access_obj_array.html
t/data/access_obj_hash.html
Index: Changes
===================================================================
RCS file: /var/spool/cvs/Petal/Changes,v
retrieving revision 1.127
retrieving revision 1.128
diff -LChanges -LChanges -u -r1.127 -r1.128
--- Changes
+++ Changes
@@ -4,6 +4,7 @@
- Added Cookbook.pod documentation and associated tests from William McKee
- Removed references to HTML::TreeBuilder and XML::Parser (William McKee)
- Skip test 071 when URI.pm not installed (William McKee)
+ - Added tests 085 & 086 demonstrating breakage when using {disk,mem} cache and multi-language includes
2.15 Wed Jan 5 15:31:00 2005
- Fixed some 'used of uninitialized values' warnings
--- /dev/null
+++ t/086_lang_include_diskcache.t
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+##############################################################################
+# Tests the 'language' option (and 'lang' alias) to Petal->new.
+# Uses t/data/language/*
+#
+
+# this is identical to t/052_Opt_language but with DISK_CACHE=1
+
+use Test::More 'no_plan';
+
+use warnings;
+use lib 'lib';
+
+use Petal;
+use File::Spec;
+
+$Petal::DISK_CACHE = 1;
+$Petal::MEMORY_CACHE = 0;
+
+my $data_dir = File::Spec->catdir('t', 'data');
+my $file = 'language';
+
+my @args = (
+ replace => 'Replacement Text',
+ content => 'Content Here',
+ attribute => 'An attribute',
+ elements => [ 'one', 'two' ],
+);
+
+
+# Try processing a template with a language and an include
+
+my $template = new Petal (file => $file, base_dir => $data_dir, language => 'fr');
+
+is($template->language, 'fr', 'correct language requested (fr)');
+
+$@ = '';
+$output = eval { $template->process(@args) };
+
+ok(!$@, "template with language and includes successfully processed");
+like($output, qr{^\s*
+ <p>\s+
+ <span>Bonjour,\sMonde\s\(fr\)</span>\s+
+ </p>
+}x, "output is correct");
+
+
+# Same again but using 'lang' option alias
+
+$template = new Petal (file => $file, base_dir => $data_dir, lang => 'fr-CA');
+
+is($template->language, 'fr-CA', 'correct language requested (fr-CA)');
+
+$@ = '';
+$output = eval { $template->process(@args) };
+
+ok(!$@, "template with lang and includes successfully processed");
+TODO: {
+ local $TODO = 'Memory cache breakage';
+like($output, qr{^\s*
+ <p>\s+
+ <span>Bonjour,\sMonde\s\(fr-CA\)</span>\s+
+ </p>
+}x, "output is correct");
+};
--- /dev/null
+++ t/085_lang_include_memcache.t
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+##############################################################################
+# Tests the 'language' option (and 'lang' alias) to Petal->new.
+# Uses t/data/language/*
+#
+
+# this is identical to t/052_Opt_language but with MEMORY_CACHE=1
+
+use Test::More 'no_plan';
+
+use warnings;
+use lib 'lib';
+
+use Petal;
+use File::Spec;
+
+$Petal::DISK_CACHE = 0;
+$Petal::MEMORY_CACHE = 1;
+
+my $data_dir = File::Spec->catdir('t', 'data');
+my $file = 'language';
+
+my @args = (
+ replace => 'Replacement Text',
+ content => 'Content Here',
+ attribute => 'An attribute',
+ elements => [ 'one', 'two' ],
+);
+
+
+# Try processing a template with a language and an include
+
+my $template = new Petal (file => $file, base_dir => $data_dir, language => 'fr');
+
+is($template->language, 'fr', 'correct language requested (fr)');
+
+$@ = '';
+$output = eval { $template->process(@args) };
+
+ok(!$@, "template with language and includes successfully processed");
+like($output, qr{^\s*
+ <p>\s+
+ <span>Bonjour,\sMonde\s\(fr\)</span>\s+
+ </p>
+}x, "output is correct");
+
+
+# Same again but using 'lang' option alias
+
+$template = new Petal (file => $file, base_dir => $data_dir, lang => 'fr-CA');
+
+is($template->language, 'fr-CA', 'correct language requested (fr-CA)');
+
+$@ = '';
+$output = eval { $template->process(@args) };
+
+ok(!$@, "template with lang and includes successfully processed");
+TODO: {
+ local $TODO = 'Memory cache breakage';
+like($output, qr{^\s*
+ <p>\s+
+ <span>Bonjour,\sMonde\s\(fr-CA\)</span>\s+
+ </p>
+}x, "output is correct");
+};
More information about the MKDoc-commit
mailing list