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

Annotation of todotxt/Text-Todo/t/special_tags.t, Revision 1.7

1.1       andrew      1: #===============================================================================
                      2: #
                      3: #         FILE:  special_tags.t
                      4: #
                      5: #  DESCRIPTION:  Test special tags
                      6: #
                      7: #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
                      8: #      COMPANY:  Red River Communications
                      9: #      CREATED:  01/09//10 17:43
1.7     ! andrew     10: #     REVISION:  $AFresh1: special_tags.t,v 1.6 2010/02/13 23:06:34 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.7     ! andrew     16: use Test::More tests => 30;
1.1       andrew     17:
1.5       andrew     18: my $class;
                     19: BEGIN {
                     20:        $class = 'Text::Todo::Entry';
                     21:        use_ok( $class, "use $class" )
                     22: }
1.1       andrew     23:
                     24: diag("Testing special tags in $class $Text::Todo::Entry::VERSION");
                     25:
                     26: my %sample = (
1.7     ! andrew     27:     text     => '(B) @home @work send email to mailto:andrew@cpan.org DUE:2011-01-01 +say_thanks',
1.1       andrew     28:
1.6       andrew     29:     known_tags => {
                     30:         context => '@',
                     31:         project => '+',
                     32:         due_date => 'DUE:',
                     33:     },
                     34:
1.7     ! andrew     35:     extra_tags => { 'email' => 'mailto:' },
        !            36:
1.1       andrew     37:     priority  => 'B',
                     38:     contexts  => [ 'home', 'work' ],
                     39:     projects  => ['say_thanks'],
                     40:     due_dates => ['2011-01-01'],
1.7     ! andrew     41:     emails    => ['andrew@cpan.org'],
1.1       andrew     42: );
                     43:
                     44: my $e = new_ok($class, [ {text => $sample{text}, tags => { due_date => 'DUE:' }} ]);
1.6       andrew     45:
1.1       andrew     46: is( $e->text,     $sample{text},     'Make sure entry matches' );
                     47: is( $e->priority, $sample{priority}, 'check priority' );
                     48:
1.7     ! andrew     49: my $known_tags = $sample{known_tags};
        !            50: check_tags($e, $known_tags);
        !            51:
        !            52: foreach my $key (keys %{ $sample{extra_tags} }) {
        !            53:     ok( $e->learn_tag( $key, $sample{extra_tags}{$key} ), "Learn tag [$key]");
        !            54:     $known_tags->{ $key } = $sample{extra_tags}{$key};
        !            55: }
        !            56: check_tags($e, $known_tags);
1.1       andrew     57:
1.2       andrew     58: #done_testing();
1.7     ! andrew     59:
        !            60: sub check_tags {
        !            61:     my ($e, $known_tags) = @_;
        !            62:
        !            63:     is_deeply( $e->known_tags, $known_tags, 'check known_tags' );
        !            64:
        !            65:     foreach my $key (keys %{ $known_tags }) {
        !            66:         my $t = $key . 's';
        !            67:         my $in = 'in_' . $key;
        !            68:
        !            69:         is_deeply( [ $e->$t ], $sample{$t}, "check [$t]" );
        !            70:
        !            71:         ok( !$e->$in(''), "check not [$in]");
        !            72:
        !            73:         foreach my $value (@{ $sample{$t} }) {
        !            74:             ok( $e->$in($value), "check [$in] [$value]");
        !            75:         }
        !            76:     }
        !            77: }

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