[Templates-cvs] cvs commit: Template2/t stash.t
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 06/01/30 13:33:57
Modified: t stash.t
Log:
* added tests for Dave Howorth's fix to make stash stricter about what
it considers to be a missing object method.
Revision Changes Path
2.16 +41 -3 Template2/t/stash.t
Index: stash.t
===================================================================
RCS file: /template-toolkit/Template2/t/stash.t,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -r2.15 -r2.16
--- stash.t 2006/01/29 11:38:22 2.15
+++ stash.t 2006/01/30 13:33:57 2.16
@@ -12,7 +12,7 @@
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
-# $Id: stash.t,v 2.15 2006/01/29 11:38:22 abw Exp $
+# $Id: stash.t,v 2.16 2006/01/30 13:33:57 abw Exp $
#
#========================================================================
@@ -29,6 +29,26 @@
#$Template::Parser::DEBUG = $DEBUG;
#$Template::Directive::PRETTY = $DEBUG;
+#------------------------------------------------------------------------
+# define some simple objects for testing
+#------------------------------------------------------------------------
+
+package ListObject;
+package HashObject;
+
+sub hello {
+ my $self = shift;
+ return "Hello $self->{ planet }";
+}
+
+sub goodbye {
+ my $self = shift;
+ return $self->no_such_method();
+}
+
+package main;
+
+
$Template::Config::STASH = 'Template::Stash';
my $count = 20;
@@ -46,8 +66,13 @@
obj => bless({
name => 'an object',
}, 'AnObject'),
- listobj => bless([10, 20, 30], 'AListObject')
-
+ hashobj => bless({ planet => 'World' }, 'HashObject'),
+ listobj => bless([10, 20, 30], 'ListObject'),
+ clean => sub {
+ my $error = shift;
+ $error =~ s/\s+at.*$//;
+ return $error;
+ },
};
my $stash = Template::Stash->new($data);
@@ -238,3 +263,16 @@
=[% size %]=
-- expect --
==
+
+# test Dave Howorth's patch (v2.15) which makes the stash more strict
+# about what it considers to be a missing method error
+
+-- test --
+[% hashobj.hello %]
+-- expect --
+Hello World
+
+-- test --
+[% TRY; hashobj.goodbye; CATCH; "ERROR: "; clean(error); END %]
+-- expect --
+ERROR: undef error - Can't locate object method "no_such_method" via package "HashObject"