summaryrefslogtreecommitdiff
path: root/t/tests/fileset.t
blob: 7723dc250ba9d1436d963e18e84fee571b3e63e9 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- mode: perl6 -*- 
use Test;
use lib 't/lib';
use Test::WebCoso;
use File::Temp;
use WebCoso::FileSet;
 
my $testdir = tempdir.IO;
 
$testdir.child('document.it.tt').spurt('it');
$testdir.child('document.en.rest.txt').spurt('en');
$testdir.child('du2xhtml.xsl').spurt('<>');
 
subtest {
    my $fs1 = WebCoso::FileSet.new(
        basename=>'document',
        ext=>'tt',
        path=>$testdir,
    );
    cmp-files(
        $fs1,
        it => { $^x.contents eq 'it' } },
        'simple ext works',
    );
 
    my $fs2 = WebCoso::FileSet.new(
        basename=>'document',
        ext=>'rest.txt',
        path=>$testdir,
    );
    cmp-files(
        $fs2,
        en => { $^x.contents eq 'en' } },
        'harder ext works',
    );
 
    my $fs3 = WebCoso::FileSet.new(
        files => [$testdir.child('du2xhtml.xsl')],
    );
    cmp-files(
        $fs3,
        '' => { $^x.contents eq '<>' } },
        'direct files works',
    );
 
    my $fs4 = WebCoso::FileSet.new(
        files-hash => {
            xml => $testdir.child('du2xhtml.xsl'),
            it => $testdir.child('document.it.tt'),
        }
    );
    cmp-files(
        $fs4,
        {
            xml => { $^x.contents eq '<>' },
            it => { $^x.contents eq 'it' },
        },
        'files hash works',
    );
},'construction';
 
subtest {
    my $fs-merged = WebCoso::FileSet.new(
        basename=>'document',
        ext=>'tt',
        path=>$testdir,
    ).merged-with(WebCoso::FileSet.new(
        basename=>'document',
        ext=>'rest.txt',
        path=>$testdir,
    ));
    cmp-files(
        $fs-merged,
        {
            it => { $^x.contents eq 'it' },
            en => { $^x.contents eq 'en' },
        },
        'merging works',
    );
},'merging';
 
subtest {
    my $fs1 = WebCoso::FileSet.new(
        basename=>'document',
        ext=>'tt',
        path=>$testdir,
    );
    $fs1.set-for-lang('en',$testdir.child('document.en.rest.txt'));
    cmp-files(
        $fs1,
        {
            it => { $^x.contents eq 'it' },
            en => { $^x.contents eq 'en' },
        },
        'set-for-lang works',
    );
},'set-for-lang';
 
done-testing;