=================================================================== RCS file: /cvs/todotxt/Text-Todo/t/list.t,v retrieving revision 1.9 retrieving revision 1.16 diff -u -r1.9 -r1.16 --- todotxt/Text-Todo/t/list.t 2010/01/11 19:52:06 1.9 +++ todotxt/Text-Todo/t/list.t 2010/02/14 06:08:07 1.16 @@ -8,20 +8,23 @@ # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org # COMPANY: Red River Communications # CREATED: 01/07/10 19:11 -# REVISION: $AFresh1: list.t,v 1.8 2010/01/10 22:39:26 andrew Exp $ +# REVISION: $AFresh1: list.t,v 1.15 2010/02/13 23:26:44 andrew Exp $ #=============================================================================== use strict; use warnings; -use Test::More tests => 53; +use Test::More tests => 58; use File::Temp qw/ tempdir /; -use Data::Dumper; +use File::Spec; -my $class = 'Text::Todo'; +my $class; -BEGIN: { use_ok( $class, "use $class" ) } +BEGIN { + $class = 'Text::Todo'; + use_ok( $class, "use $class" ); +} diag("Testing entry $class $Text::Todo::VERSION"); @@ -29,10 +32,18 @@ my @orig_list; ok( @orig_list = $orig->list, 'get orig list' ); -is( $orig->file('todo_file'), 't/todo.list.txt', 'orig todo_file matches' ); -is( $orig->file('done_file'), 't/done.list.txt', 'orig done_file matches' ); +is( $orig->file('todo_file'), + File::Spec->catfile( 't', 'todo.list.txt' ), + 'orig todo_file matches' +); +is( $orig->file('done_file'), + File::Spec->catfile( 't', 'done.list.txt' ), + 'orig done_file matches' +); is( $orig->file('report_file'), - 't/report.list.txt', 'orig report_file matches' ); + File::Spec->catfile( 't', 'report.list.txt' ), + 'orig report_file matches' +); my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 ); my $copy = new_ok($class); @@ -40,18 +51,19 @@ foreach my $e (@orig_list) { ok( $copy->add($e), 'add entry from orginal list' ); } -ok( $copy->save( $todo_dir . '/todo.txt' ), 'save the copy' ); +ok( $copy->save( File::Spec->catfile( $todo_dir, 'todo.txt' ) ), + 'save the copy' ); is( $copy->file('todo_file'), - $todo_dir . '/todo.txt', + File::Spec->catfile( $todo_dir, 'todo.txt' ), 'copy todo_file matches' ); is( $copy->file('done_file'), - $todo_dir . '/done.txt', + File::Spec->catfile( $todo_dir, 'done.txt' ), 'copy done_file matches' ); is( $copy->file('report_file'), - $todo_dir . '/report.txt', + File::Spec->catfile( $todo_dir, 'report.txt' ), 'copy report_file matches' ); my @copy_list; @@ -80,6 +92,22 @@ is( $copy_list[1]->text, $entry_to_move->text, 'entry is in the new position' ); +my $tags; +ok( $tags = $copy->known_tags, 'known_tags for current list' ); +is_deeply( + $tags, + { 'context' => '@', 'project' => '+' }, + 'got the tags we expected' +); + +ok( $copy->learn_tag('due_date', 'DUE:'), "Learn due_date tag" ); +ok( $tags = $copy->known_tags, 'known_tags for current list' ); +is_deeply( + $tags, + { 'context' => '@', 'project' => '+', 'due_date' => 'DUE:' }, + 'got the tags we expected' +); + my @projects; ok( @projects = $copy->listproj, 'listproj for current list' ); is_deeply( @@ -120,7 +148,10 @@ my $file; ok( $file = $copy->file('done_file'), 'get the done_file name' ); -is( $file, $todo_dir . '/done.txt', 'the done_file name what we expected?' ); +is( $file, + File::Spec->catfile( $todo_dir, 'done.txt' ), + 'the done_file name what we expected?' +); ok( $copy->addto( $file, 'added text' ), 'Add text to file' );