=================================================================== RCS file: /cvs/todotxt/Text-Todo/t/special_tags.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- todotxt/Text-Todo/t/special_tags.t 2010/02/13 23:06:34 1.6 +++ todotxt/Text-Todo/t/special_tags.t 2010/02/14 00:50:56 1.7 @@ -7,13 +7,13 @@ # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org # COMPANY: Red River Communications # CREATED: 01/09//10 17:43 -# REVISION: $AFresh1: special_tags.t,v 1.5 2010/01/15 19:50:15 andrew Exp $ +# REVISION: $AFresh1: special_tags.t,v 1.6 2010/02/13 23:06:34 andrew Exp $ #=============================================================================== use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 30; my $class; BEGIN { @@ -24,7 +24,7 @@ diag("Testing special tags in $class $Text::Todo::Entry::VERSION"); my %sample = ( - text => '(B) @home @work send email to andrew@cpan.org DUE:2011-01-01 +say_thanks', + text => '(B) @home @work send email to mailto:andrew@cpan.org DUE:2011-01-01 +say_thanks', known_tags => { context => '@', @@ -32,21 +32,46 @@ due_date => 'DUE:', }, + extra_tags => { 'email' => 'mailto:' }, + priority => 'B', contexts => [ 'home', 'work' ], projects => ['say_thanks'], due_dates => ['2011-01-01'], + emails => ['andrew@cpan.org'], ); my $e = new_ok($class, [ {text => $sample{text}, tags => { due_date => 'DUE:' }} ]); -is_deeply( $e->known_tags, $sample{known_tags}, 'check known_tags' ); - 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' ); -is_deeply( [ $e->due_dates ], $sample{due_dates}, 'check due_dates'); +my $known_tags = $sample{known_tags}; +check_tags($e, $known_tags); +foreach my $key (keys %{ $sample{extra_tags} }) { + ok( $e->learn_tag( $key, $sample{extra_tags}{$key} ), "Learn tag [$key]"); + $known_tags->{ $key } = $sample{extra_tags}{$key}; +} +check_tags($e, $known_tags); + #done_testing(); + +sub check_tags { + my ($e, $known_tags) = @_; + + is_deeply( $e->known_tags, $known_tags, 'check known_tags' ); + + foreach my $key (keys %{ $known_tags }) { + my $t = $key . 's'; + my $in = 'in_' . $key; + + is_deeply( [ $e->$t ], $sample{$t}, "check [$t]" ); + + ok( !$e->$in(''), "check not [$in]"); + + foreach my $value (@{ $sample{$t} }) { + ok( $e->$in($value), "check [$in] [$value]"); + } + } +}