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

Diff for /todotxt/Text-Todo/t/list.t between version 1.1 and 1.2

version 1.1, 2010/01/08 04:38:44 version 1.2, 2010/01/09 05:00:21
Line 8 
Line 8 
 #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org  #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
 #      COMPANY:  Red River Communications  #      COMPANY:  Red River Communications
 #      CREATED:  01/07/10 19:11  #      CREATED:  01/07/10 19:11
 #     REVISION:  $RedRiver$  #     REVISION:  $RedRiver: list.t,v 1.1 2010/01/08 04:38:44 andrew Exp $
 #===============================================================================  #===============================================================================
   
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Test::More tests => 2;  use Test::More;    #tests => 2;
   
   use File::Temp qw/ tempdir /;
   use Data::Dumper;
   
 my $class = 'Text::Todo';  my $class = 'Text::Todo';
   
 BEGIN: { use_ok( $class, "use $class" ) }  BEGIN: { use_ok( $class, "use $class" ) }
   
 diag("Testing entry $class $Text::Todo::VERSION");  diag("Testing entry $class $Text::Todo::VERSION");
   
 my $e = new_ok( $class, [ 't/todo.list.txt' ] );  my $orig = new_ok( $class, ['t/todo.list.txt'] );
   my @orig_list;
   ok( @orig_list = $orig->list, 'get orig list' );
   
 my %commands = (  is( $orig->file('todo_file'), 't/todo.list.txt', 'orig todo_file matches' );
     add      => {},  is( $orig->file('done_file'), 't/done.list.txt', 'orig done_file matches' );
     archive  => {},  is( $orig->file('report_file'),
     del      => {},      't/report.list.txt', 'orig report_file matches' );
     list     => {},  
     listall  => {},  my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 );
     listcon  => {},  my $copy = new_ok($class);
     listfile => {},  
     listpri  => {},  foreach my $e (@orig_list) {
     listproj => {},      ok( $copy->add($e), 'add entry from orginal list' );
     move     => {},  }
     replace  => {},  ok( $copy->save( $todo_dir . '/todo.txt' ), 'save the copy' );
     report   => {},  
   is( $copy->file('todo_file'),
       $todo_dir . '/todo.txt',
       'copy todo_file matches'
 );  );
   is( $copy->file('done_file'),
       $todo_dir . '/done.txt',
       'copy done_file matches'
   );
   is( $copy->file('report_file'),
       $todo_dir . '/report.txt',
       'copy report_file matches'
   );
   my @copy_list;
   ok( @copy_list = $copy->list, 'get copy list' );
   
 my %aliases = (  for my $id ( 0 .. $#orig_list ) {
     a     => 'add',      is( $copy_list[$id]->text, $orig_list[$id]->text, "Entry $id matches" );
     rm    => 'del',  }
     ls    => 'list',  
     lsa   => 'listall',  $orig = undef;
     lsc   => 'listcon',  
     lf    => 'listfile',  my @pri_list;
     lspri => 'listpri',  ok( @pri_list = $copy->listpri, 'load priority item' );
     lsprj => 'listproj',  is( scalar @pri_list, 1, 'only 1 item in the priority list' );
     mv    => 'move',  is( $pri_list[0]->text, '(A) entry 1 @one +uno', 'priority item is correct' );
   
   my $entry_to_move = $copy_list[-1];
   ok( $copy->move( $entry_to_move, 1 ), 'move entry to position 1' );
   ok( @copy_list = $copy->list, 'update our list' );
   is( $copy_list[1]->text, $entry_to_move->text,
       'entry is in the new position' );
   
   $entry_to_move = $copy_list[3];
   ok( $copy->move( 3, 1 ), 'move entry 3 to position 1' );
   ok( @copy_list = $copy->list, 'update our list' );
   is( $copy_list[1]->text, $entry_to_move->text,
       'entry is in the new position' );
   
   my @projects;
   ok( @projects = $copy->listproj, 'listproj for current list' );
   is_deeply(
       \@projects,
       [ 'delete', 'dos', 'uno' ],
       'got the projects we expected'
 );  );
   
   for my $id ( 0 .. $#copy_list ) {
       my $e = $copy_list[$id];
       if ( $e->in_project('delete') ) {
           ok( $copy->del($e), "deleting entry $id" );
           isnt( $copy->list->[$id]->text, $e->text, 'Entry seems to be gone' );
       }
   }
   
   @projects;
   ok( @projects = $copy->listproj, 'listproj for current list' );
   is_deeply( \@projects, [ 'dos', 'uno' ], 'got the projects we expected' );
   
   TODO: {
       local $TODO = 'No tests for archive and it isn\'t even written yet';
       ok( $copy->archive );
   }
   
   TODO: {
       local $TODO = 'No tests for addto and it isn\'t even written yet';
       ok( $copy->addto );
   }
   
   TODO: {
       local $TODO = 'No tests for listfile and it isn\'t even written yet';
       ok( $copy->listfile );
   }
   
   done_testing();

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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