aboutsummaryrefslogtreecommitdiff
path: root/t/fcp-01.t
blob: 9ceaf77ff93234dd4df2040aae2c7712ef2e7712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl 
use strict;
use warnings;
use Test::More qw(no_plan);
use Path::Class;
 
BEGIN { use_ok('File::Cache::Parsed'or die }
 
my $fc=File::Cache::Parsed->new();
my %calls;
$fc->add_parser(qr{\.t$} => sub { $calls{t}++;return ['t',@_] });
$fc->add_parser(qr{\.pm$} => sub { $calls{pm}++;return ['pm',@_] });
 
my $base=file(__FILE__)->parent->parent;
my $module_file=$base->file('lib','File','Cache','Parsed.pm');
my $module_contents=$module_file->slurp;
my $test_file=$base->file('t','fcp-01.t');
my $test_contents=$test_file->slurp;
 
is_deeply($fc->get($module_file->stringify),
          ['pm',$module_file->stringify,$module_contents]);
is_deeply($fc->get($test_file->stringify),
          ['t',$test_file->stringify,$test_contents]);
is($calls{t},1);
is($calls{pm},1);
is_deeply($fc->get($test_file->stringify),
          ['t',$test_file->stringify,$test_contents]);
is($calls{t},1);
is($calls{pm},1);
$fc->del_parser(qr{\.t$});
is($fc->get($test_file->stringify),
   $test_contents);