[Templates-cvs] cvs commit: Template2/t stash-xs.t

cvs@template-toolkit.org cvs@template-toolkit.org


cvs         05/03/03 19:18:22

  Modified:    t        stash-xs.t
  Log:
  * added test for die_object() bug.
  
  Revision  Changes    Path
  2.6       +35 -9     Template2/t/stash-xs.t
  
  Index: stash-xs.t
  ===================================================================
  RCS file: /template-toolkit/Template2/t/stash-xs.t,v
  retrieving revision 2.5
  retrieving revision 2.6
  diff -u -r2.5 -r2.6
  --- stash-xs.t	2002/08/12 11:07:17	2.5
  +++ stash-xs.t	2005/03/03 19:18:22	2.6
  @@ -13,7 +13,7 @@
   # This is free software; you can redistribute it and/or modify it
   # under the same terms as Perl itself.
   #
  -# $Id: stash-xs.t,v 2.5 2002/08/12 11:07:17 abw Exp $
  +# $Id: stash-xs.t,v 2.6 2005/03/03 19:18:22 abw Exp $
   #
   #========================================================================
   
  @@ -32,21 +32,28 @@
       skip_all('cannot load Template::Stash::XS');
   }
   
  +package Buggy;
  +sub new { bless {}, shift }
  +sub croak { my $self = shift; die @_ }
  +package main;
  +
   my $count = 20;
   my $data = {
       foo => 10,
       bar => {
  -	baz => 20,
  +        baz => 20,
       },
       baz => sub {
  -	return {
  -	    boz => ($count += 10),
  -	    biz => (shift || '<undef>'),
  -	};
  +        return {
  +            boz => ($count += 10),
  +            biz => (shift || '<undef>'),
  +        };
       },
  -    obj => bless {
  -	name => 'an object',
  -    }, 'AnObject',
  +    obj => bless({
  +        name => 'an object',
  +    }, 'AnObject'),
  +    correct => sub { die @_ },
  +    buggy => Buggy->new(),
   };
   
   my $stash = Template::Stash::XS->new($data);
  @@ -236,3 +243,22 @@
   -- expect --
   ==
   
  +-- test --
  +[% USE Dumper;
  +   TRY;
  +     correct(["hello", "there"]);
  +   CATCH;
  +     error.info.join(', ');
  +   END;
  +%]
  +==
  +[% TRY;
  +     buggy.croak(["hello", "there"]);
  +   CATCH;
  +     error.info.join(', ');
  +   END;
  +%]
  +-- expect --
  +hello, there
  +==
  +hello, there