From df354d91e7e315b839d5c292e386e64ca339cb07 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 11 Sep 2015 15:32:51 +0100 Subject: filesets! don't work I think I'm trying to be too clever, merging "these files make up a document, a file per language" with "these files are needed to build a result file in a certain language". Those should probably be separate classes. --- t/tests/fileset.t | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 t/tests/fileset.t (limited to 't/tests/fileset.t') diff --git a/t/tests/fileset.t b/t/tests/fileset.t new file mode 100644 index 0000000..7723dc2 --- /dev/null +++ b/t/tests/fileset.t @@ -0,0 +1,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; -- cgit v1.2.3