[Templates-cvs] cvs commit: TT3/t document.t

cvs@template-toolkit.org cvs@template-toolkit.org
Thu, 11 Dec 2003 15:09:17 +0000


cvs         03/12/11 15:09:16

  Modified:    t        document.t
  Log:
  *** empty log message ***
  
  Revision  Changes    Path
  1.2       +46 -2     TT3/t/document.t
  
  Index: document.t
  ===================================================================
  RCS file: /template-toolkit/TT3/t/document.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- document.t	2003/12/10 14:17:49	1.1
  +++ document.t	2003/12/11 15:09:16	1.2
  @@ -9,7 +9,7 @@
   # This is free software; you can redistribute it and/or modify it
   # under the same terms as Perl itself.
   #
  -# $Id: document.t,v 1.1 2003/12/10 14:17:49 abw Exp $
  +# $Id: document.t,v 1.2 2003/12/11 15:09:16 abw Exp $
   #
   #========================================================================
   
  @@ -19,7 +19,8 @@
   use lib qw( ./lib ../lib );
   use Template::TT3::Base;
   use Template::TT3::Document;
  -use Test::More tests => 29;
  +use Template::TT3::Constants qw( :chomp );
  +use Test::More tests => 60;
   
   my $DEBUG = grep /^--?d(ebug)?$/, @ARGV;
   
  @@ -66,6 +67,49 @@
   is( $doc->line(), 9, 'now on line 9' );
   is( $doc->position(), '9', 'position is 9' );
   
  +
  +#------------------------------------------------------------------------
  +# test chomping options
  +#------------------------------------------------------------------------
  +
  +$doc = $pkg->new( name => 'chompdoc' );
  +ok( $doc, 'created chomping doc' );
  +
  +ok( $doc->text("hello world  \n   "), 'first line' );
  +is( ${$doc->body->[0]->[1]}, "hello world  \n   ", 'hello world etc' );
  +ok( $doc->pre_chomp(), 'pre-chomped' );
  +is( ${$doc->body->[0]->[1]}, 'hello world', 'hello world' );
  +is( $doc->position(), 2, 'on line 2' );
  +
  +ok( $doc->text("goodbye cruel world  \n   "), 'second line' );
  +ok( $doc->pre_chomp(CHOMP_COLLAPSE), 'pre-chomp collapse' );
  +is( ${$doc->body->[1]->[1]}, 'goodbye cruel world ', 'goodbye cruel world' );
  +ok( $doc->pre_chomp(CHOMP_ALL), 'pre-chomp all' );
  +is( ${$doc->body->[1]->[1]}, 'goodbye cruel world', 'goodbye again' );
  +is( $doc->position(), 3, 'on line 3' );
  +
  +ok( $doc->text(" \n more text \n "), 'third line' );
  +is( ${$doc->body->[2]->[1]}, " \n more text \n ", 'more text' );
  +is( $doc->position(), 5, 'on line 5' );
  +
  +ok( $doc->post_chomp(), 'set post-chomp' );
  +ok( $doc->text(" \n even more text \n "), 'fourth line' );
  +is( ${$doc->body->[3]->[1]}, "even more text \n ", 'even more text' );
  +ok( $doc->pre_chomp(), 'set pre-chomp' );
  +is( ${$doc->body->[3]->[1]}, "even more text", 'yet even more text' );
  +is( $doc->position(), 7, 'on line 7' );
  +
  +ok( $doc->post_chomp(CHOMP_COLLAPSE), 'set post-chomp collapse' );
  +ok( $doc->text(" \n\n yet more text \n\n "), 'fifth line' );
  +is( ${$doc->body->[4]->[1]}, " yet more text \n\n ", 'yet more text' );
  +ok( $doc->pre_chomp(), 'set pre-chomp' );
  +is( $doc->position(), 11, 'on line 11' );
  +
  +ok( $doc->post_chomp(), 'set another post-chomp' );
  +ok( $doc->body([ test => 'something' ]), 'added some body' );
  +ok( $doc->text("  \n  post chomp should be cleared  \n  "), 'should be clear' );
  +is( ${$doc->body->[6]->[1]}, "  \n  post chomp should be cleared  \n  ", 'it is' );
  +is( $doc->position(), 13, 'on line 13' );
   
   
   #------------------------------------------------------------------------