[BACK]Return to entry.t CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo / t

Diff for /todotxt/Text-Todo/t/entry.t between version 1.4 and 1.6

version 1.4, 2009/07/13 19:05:50 version 1.6, 2010/01/08 04:44:54
Line 1 
Line 1 
 #===============================================================================  #===============================================================================
 #  #
 #         FILE:  20.entry.t  #         FILE:  entry.t
 #  #
 #  DESCRIPTION:  Test an entry that we create  #  DESCRIPTION:  Test entry commands
 #  #
 #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org  #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
 #      COMPANY:  Red River Communications  #      COMPANY:  Red River Communications
 #      CREATED:  07/10/09 11:32:39  #      CREATED:  07/10/09 11:32:39
 #     REVISION:  $RedRiver: 20.entry.t,v 1.3 2009/07/13 17:50:37 andrew Exp $  #     REVISION:  $RedRiver: entry.t,v 1.5 2010/01/06 19:54:56 andrew Exp $
 #===============================================================================  #===============================================================================
   
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Test::More tests => 34;    # last test to print  use Test::More tests => 40;
   
 my $class = 'Text::Todo::Entry';  my $class = 'Text::Todo::Entry';
   
 BEGIN: { use_ok( $class, "use $class" ) }  BEGIN: { use_ok( $class, "use $class" ) }
   
 diag("Testing 20 entry $class $Text::Todo::Entry::VERSION");  diag("Testing entry $class $Text::Todo::Entry::VERSION");
   
 my $e = new_ok($class);  
   
 my %sample = (  my %sample = (
     text => '(B) @home @work send email to andrew@cpan.org +say_thanks',      text => '(B) @home @work send email to andrew@cpan.org +say_thanks',
     priority    => 'B',      priority    => 'B',
Line 34 
Line 32 
     new_context => 'car',      new_context => 'car',
 );  );
   
 ok( $e->change( $sample{text} ), 'Update entry' );  my $e = new_ok($class);
 is( $e->text,     $sample{text},     "Make sure entry matches" );  
 is( $e->priority, $sample{priority}, "check priority" );  
 is_deeply( [ $e->contexts ], $sample{contexts}, "check contexts" );  
 is_deeply( [ $e->projects ], $sample{projects}, "check projects" );  
   
   ok( $e->change( $sample{text} ), 'Update entry' );
   is( $e->text,     $sample{text},     'Make sure entry matches' );
   is( $e->priority, $sample{priority}, 'check priority' );
   is_deeply( [ $e->contexts ], $sample{contexts}, 'check contexts' );
   is_deeply( [ $e->projects ], $sample{projects}, 'check projects' );
   
 $sample{text} =~ s/^( \s* \( $sample{priority} \))/$1 $sample{prepend}/xms;  $sample{text} =~ s/^( \s* \( $sample{priority} \))/$1 $sample{prepend}/xms;
 ok( $e->prepend( $sample{prepend} ), 'Prepend entry' );  ok( $e->prepend( $sample{prepend} ), 'Prepend entry' );
 is( $e->text,     $sample{text},     "Make sure entry matches" );  is( $e->text,     $sample{text},     'Make sure entry matches' );
 is( $e->priority, $sample{priority}, "check priority" );  is( $e->priority, $sample{priority}, 'check priority' );
 is_deeply( [ $e->contexts ], $sample{contexts}, "check contexts" );  is_deeply( [ $e->contexts ], $sample{contexts}, 'check contexts' );
 is_deeply( [ $e->projects ], $sample{projects}, "check projects" );  is_deeply( [ $e->projects ], $sample{projects}, 'check projects' );
   
 $sample{text} .= ' ' . $sample{append};  $sample{text} .= ' ' . $sample{append};
 ok( $e->append( $sample{append} ), 'Append entry' );  ok( $e->append( $sample{append} ), 'Append entry' );
 is( $e->text,     $sample{text},     "Make sure entry matches" );  is( $e->text,     $sample{text},     'Make sure entry matches' );
 is( $e->priority, $sample{priority}, "check priority" );  is( $e->priority, $sample{priority}, 'check priority' );
 is_deeply( [ $e->contexts ], $sample{contexts}, "check contexts" );  is_deeply( [ $e->contexts ], $sample{contexts}, 'check contexts' );
 is_deeply( [ $e->projects ], $sample{projects}, "check projects" );  is_deeply( [ $e->projects ], $sample{projects}, 'check projects' );
   
 ok( !$e->in_project( $sample{new_project} ), 'not in new project yet' );  ok( !$e->in_project( $sample{new_project} ), 'not in new project yet' );
 push @{ $sample{projects} }, $sample{new_project};  push @{ $sample{projects} }, $sample{new_project};
 $sample{text} .= ' +' . $sample{new_project};  $sample{text} .= ' +' . $sample{new_project};
 ok( $e->append( '+' . $sample{new_project} ), 'Add project' );  ok( $e->append( '+' . $sample{new_project} ), 'Add project' );
 is( $e->text, $sample{text}, "Make sure entry matches" );  is( $e->text, $sample{text}, 'Make sure entry matches' );
 ok( $e->in_project( $sample{new_project} ), 'now in new project' );  ok( $e->in_project( $sample{new_project} ), 'now in new project' );
   
 ok( !$e->in_context( $sample{new_context} ), 'not in new context yet' );  ok( !$e->in_context( $sample{new_context} ), 'not in new context yet' );
 push @{ $sample{contexts} }, $sample{new_context};  push @{ $sample{contexts} }, $sample{new_context};
 $sample{text} .= ' @' . $sample{new_context};  $sample{text} .= ' @' . $sample{new_context};
 ok( $e->append( '@' . $sample{new_context} ), 'Add context' );  ok( $e->append( '@' . $sample{new_context} ), 'Add context' );
 is( $e->text, $sample{text}, "Make sure entry matches" );  is( $e->text, $sample{text}, 'Make sure entry matches' );
 ok( $e->in_context( $sample{new_context} ), 'now in new context' );  ok( $e->in_context( $sample{new_context} ), 'now in new context' );
   
   $sample{text} =~ s/^\(B\)\s*/(A) /gxms;
   $sample{priority} = 'A';
   ok( $e->priority('A'), 'Set priority to A' );
   is( $e->text, $sample{text}, 'Make sure entry matches' );
   is( $e->priority, 'A', 'New priority is set' );
   
   $sample{text} =~ s/^\(A\)\s*//gxms;
   $sample{priority} = '';
   ok( $e->depri(), 'Deprioritize' );
   is( $e->text, $sample{text}, 'Make sure entry matches' );
   is( $e->priority, undef, 'New priority is set' );
   
 ok( !$e->completed, 'not completed' );  ok( !$e->completed, 'not completed' );
 ok( $e->complete, 'mark as completed' );  ok( $e->complete, 'mark as completed' );
 ok( $e->completed,  'now completed' );  ok( $e->completed,  'now completed' );
 is( $e->text, 'x ' . $sample{text}, "Make sure entry matches" );  is( $e->text, 'x ' . $sample{text}, 'Make sure entry matches' );
   
 ok( $e->change(   '' ), 'Blank entry' );  ok( $e->change(   '' ), 'Blank entry' );
 is( $e->text,     '',    "Make sure entry is blank" );  is( $e->text,     '',    'Make sure entry is blank' );
 is( $e->priority, undef, "check priority is undef" );  is( $e->priority, undef, 'check priority is undef' );
 is_deeply( [ $e->contexts ], [], "check contexts are empty" );  is_deeply( [ $e->contexts ], [], 'check contexts are empty' );
 is_deeply( [ $e->projects ], [], "check projects are empty" );  is_deeply( [ $e->projects ], [], 'check projects are empty' );
   
   
   # replace
   # app => 'append',
   # prep => 'prepend',
   # dp => 'dpri',
   # p => 'pri',

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>