From f7721306bc5ec1cd29aff678dee05c09ee9e5227 Mon Sep 17 00:00:00 2001 From: "Fuji, Goro (gfx)" Date: Mon, 20 Jan 2014 08:36:05 +0900 Subject: [PATCH] add a TODO test for #95. NOTE: `cache => 1` has to behave the samy way to `cache => 0` --- MANIFEST | 3 +- t/900_bugs/040_issue95.t | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 t/900_bugs/040_issue95.t diff --git a/MANIFEST b/MANIFEST index 41be5a8a..9dcc315c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -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 diff --git a/t/900_bugs/040_issue95.t b/t/900_bugs/040_issue95.t new file mode 100644 index 00000000..fe62a7c2 --- /dev/null +++ b/t/900_bugs/040_issue95.t @@ -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; +}