| version 1.4, 2010/01/08 23:06:09 |
version 1.5, 2010/01/10 04:08:59 |
|
|
| # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org |
# AUTHOR: Andrew Fresh (AAF), andrew@cpan.org |
| # COMPANY: Red River Communications |
# COMPANY: Red River Communications |
| # CREATED: 07/09/09 11:45:52 |
# CREATED: 07/09/09 11:45:52 |
| # REVISION: $RedRiver: read_todo.t,v 1.3 2010/01/06 19:54:56 andrew Exp $ |
# REVISION: $RedRiver: read_todo.t,v 1.4 2010/01/08 23:06:09 andrew Exp $ |
| #=============================================================================== |
#=============================================================================== |
| |
|
| use strict; |
use strict; |
| use warnings; |
use warnings; |
| use File::Spec; |
use File::Spec; |
| use File::Temp qw/ tempdir /; |
use File::Temp qw/ tempdir /; |
| use Test::More tests => 106; |
use Test::More tests => 122; |
| |
|
| my $todo_file = File::Spec->catfile( 't', 'todo1.txt' ); |
my $todo_file = File::Spec->catfile( 't', 'todo1.txt' ); |
| my $tempdir = tempdir( 'todotxt-XXXXXXX', CLEANUP => 1 ); |
my $tempdir = tempdir( 'todotxt-XXXXXXX', CLEANUP => 1 ); |
|
|
| priority => 'B', |
priority => 'B', |
| contexts => ['phone'], |
contexts => ['phone'], |
| projects => ['GarageSale'], |
projects => ['GarageSale'], |
| do => undef, |
done => undef, |
| }, |
}, |
| { text => |
{ text => |
| '+GarageSale @home post signs around the neighborhood DUE:2006-08-01', |
'+GarageSale @home post signs around the neighborhood DUE:2006-08-01', |
| priority => undef, |
priority => undef, |
| contexts => ['home'], |
contexts => ['home'], |
| projects => ['GarageSale'], |
projects => ['GarageSale'], |
| do => undef, |
done => undef, |
| }, |
}, |
| { text => 'X eat meatballs @home', |
{ text => 'X eat meatballs @home', |
| priority => undef, |
priority => undef, |
| contexts => ['home'], |
contexts => ['home'], |
| projects => [], |
projects => [], |
| do => 'X', |
done => 'X', |
| }, |
}, |
| { text => '(A) @phone thank Mom for the meatballs WAIT', |
{ text => '(A) @phone thank Mom for the meatballs WAIT', |
| priority => 'A', |
priority => 'A', |
| contexts => ['phone'], |
contexts => ['phone'], |
| projects => [], |
projects => [], |
| do => undef, |
done => undef, |
| }, |
}, |
| |
{ text => '', |
| |
priority => undef, |
| |
contexts => [], |
| |
projects => [], |
| |
done => undef, |
| |
}, |
| { text => '@shopping Eskimo pies', |
{ text => '@shopping Eskimo pies', |
| priority => undef, |
priority => undef, |
| contexts => ['shopping'], |
contexts => ['shopping'], |
| projects => [], |
projects => [], |
| do => undef, |
done => undef, |
| }, |
}, |
| { text => 'email andrew@cpan.org for help +report_bug @wherever', |
{ text => 'email andrew@cpan.org for help +report_bug @wherever', |
| priority => undef, |
priority => undef, |
| contexts => ['wherever'], |
contexts => ['wherever'], |
| projects => ['report_bug'], |
projects => ['report_bug'], |
| do => undef, |
done => undef, |
| }, |
}, |
| ); |
); |
| |
|
|
|
| priority => undef, |
priority => undef, |
| contexts => ['continually'], |
contexts => ['continually'], |
| projects => ['test+everything'], |
projects => ['test+everything'], |
| do => undef, |
done => undef, |
| ); |
); |
| |
|
| BEGIN: { use_ok( 'Text::Todo', 'use Text::Todo' ) } |
BEGIN: { use_ok( 'Text::Todo', 'use Text::Todo' ) } |
|
|
| ok( $list = $t->list, 'Get list from ' . $file ); |
ok( $list = $t->list, 'Get list from ' . $file ); |
| |
|
| for my $id ( 0 .. $#todos ) { |
for my $id ( 0 .. $#todos ) { |
| test_todo( $todos[$id], $list->[$id], $id); |
test_todo( $todos[$id], $list->[$id], $id ); |
| } |
} |
| } |
} |
| |
|
| sub test_todo { |
sub test_todo { |
| my ($sample, $read, $id) = @_; |
my ( $sample, $read, $id ) = @_; |
| |
|
| is( $read->text, $sample->{text}, "check text [$id]" ); |
is( $read->text, $sample->{text}, "check text [$id]" ); |
| is( $read->priority, $sample->{priority}, "check priority [$id]" ); |
is( $read->priority, $sample->{priority}, "check priority [$id]" ); |
| is( $read->done, $sample->{do}, "check completion [$id]" ); |
is( $read->done, $sample->{done}, "check completion [$id]" ); |
| is_deeply( |
is_deeply( |
| [ $read->contexts ], |
[ $read->contexts ], |
| $sample->{contexts}, |
$sample->{contexts}, |
| "check contexts [$id]" |
"check contexts [$id]" |
| ); |
); |
| is_deeply( |
is_deeply( |
| [ $read->projects ], |
[ $read->projects ], |
| $sample->{projects}, |
$sample->{projects}, |
| "check projects [$id]" |
"check projects [$id]" |
| ); |
); |
| } |
} |