Skip to content

Commit

Permalink
add a TODO test for #95.
Browse files Browse the repository at this point in the history
NOTE: `cache => 1` has to behave the samy way to `cache => 0`
  • Loading branch information
gfx committed Jan 19, 2014
1 parent 73e8cc6 commit f772130
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ t/900_bugs/035_issue81_tiedhash.t
t/900_bugs/036_vpath_utf8.t
t/900_bugs/037_text_str_key.t
t/900_bugs/038_conbine_flaged_utf8_and_other.t
t/900_bugs/039_issue95.t
t/900_bugs/039_issue96.t
t/900_bugs/040_issue95.t
t/900_bugs/issue79/tmpl/contentA.tt
t/900_bugs/issue79/tmpl/contentB.tt
t/900_bugs/issue79/tmpl/wrapperA.tt
Expand Down
66 changes: 66 additions & 0 deletions t/900_bugs/040_issue95.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!perl
# https://github.com/xslate/p5-Text-Xslate/issues/95
use strict;
use warnings;
use Fatal qw(open close);
use File::Path qw(remove_tree);
use Test::More tests => 2;

use Text::Xslate;

# here's some test template files
my $base_a = <<'EOF';
here is base A
: block body -> {}
EOF

my $sub_a = <<'EOF';
: cascade base
: override body {
this is sub A
: }
EOF

my $sub_b = <<'EOF';
: cascade base
: override body {
this is sub B
: }
EOF

# remove old directories if they exist and re-create
remove_tree('path_a', 'path_b');
END { remove_tree('path_a', 'path_b') }
mkdir 'path_a';
mkdir 'path_b';

write_file('path_a/base.tx', $base_a);
write_file('path_a/sub.tx', $sub_a);

my $tx = Text::Xslate->new(
path => ['path_b', 'path_a'],

cache => 1,
);

my $out = $tx->render('sub.tx');

# expect both base and sub A since there is nothing in path B
is($out, "here is base A\nthis is sub A\n", "cascade with base in same directory");

# now a new path_b sub file, and render again
write_file('path_b/sub.tx', $sub_b);
my $out2 = $tx->render('sub.tx');

# we should get the A base (since there is no B base) with the B sub (since that is first in path)
{ local $TODO = 'not yet';
is($out2, "here is base A\nthis is sub B\n", "cascade with base in different directory");
}
done_testing;

sub write_file {
my($path, $content) = @_;
open my $fh, ">", $path;
print $fh $content;
close $fh;
}

0 comments on commit f772130

Please sign in to comment.