X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/7e3cfbb8a475189fb100990cff348647fce4b63f..7c78e35c5908561b2dcf963779887d7aed05d1d3:/t/preprocess.t diff --git a/t/preprocess.t b/t/preprocess.t index 9b029281f..2211e8471 100755 --- a/t/preprocess.t +++ b/t/preprocess.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 17; +use Test::More tests => 34; BEGIN { use_ok("IkiWiki"); } @@ -23,7 +23,19 @@ $IkiWiki::hooks{preprocess}{foo}{call}=sub { is(IkiWiki::preprocess("foo", "foo", "[[foo]]", 0, 0), "[[foo]]", "not wikilink"); is(IkiWiki::preprocess("foo", "foo", "[[foo ]]", 0, 0), "foo()", "simple"); +is(IkiWiki::preprocess("foo", "foo", "[[!foo ]]", 0, 0), "foo()", "prefixed"); +is(IkiWiki::preprocess("foo", "foo", "[[!foo]]", 0, 0), "[[!foo]]", "prefixed, no space"); is(IkiWiki::preprocess("foo", "foo", "[[foo a=1]]", 0, 0), "foo(a => 1)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="1"]]}, 0, 0), "foo(a => 1)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="""1"""]]}, 0, 0), "foo(a => 1)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a=""]]}, 0, 0), "foo(a)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="" b="1"]]}, 0, 0), "foo(a, b => 1)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a=""""""]]}, 0, 0), "foo(a)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="""""" b="1"]]}, 0, 0), "foo(a, b => 1)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="""""" b="""1"""]]}, 0, 0), "foo(a, b => 1)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="""""" b=""""""]]}, 0, 0), "foo(a, b)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="" b=""""""]]}, 0, 0), "foo(a, b)"); +is(IkiWiki::preprocess("foo", "foo", q{[[foo a="" b="""1"""]]}, 0, 0), "foo(a, b => 1)"); is(IkiWiki::preprocess("foo", "foo", "[[foo a=\"1 2 3 4\"]]", 0, 0), "foo(a => 1 2 3 4)"); is(IkiWiki::preprocess("foo", "foo", "[[foo ]] then [[foo a=2]]", 0, 0), "foo() then foo(a => 2)"); @@ -49,11 +61,23 @@ is(IkiWiki::preprocess("foo", "foo", '[[foo a="""'.$multiline.'""" b="foo"]]', 0 "foo(a => $multiline, b => foo)"); is(IkiWiki::preprocess("foo", "foo", '[[foo a="""'."\n".$multiline."\n".'""" b="foo"]]', 0, 0), "foo(a => $multiline, b => foo)", "leading/trailing newline stripped"); +my $long='[[foo a="""'.("a" x 100000).''; +is(IkiWiki::preprocess("foo", "foo", $long, 0, 0), $long, + "unterminated triple-quoted string inside unterminated directive(should not warn about over-recursion)"); +is(IkiWiki::preprocess("foo", "foo", $long."]]", 0, 0), $long."]]", + "unterminated triple-quoted string is not treated as a bare word"); + +is(IkiWiki::preprocess("foo", "foo", "[[!foo a=< $multiline)", "nested strings via heredoc (for key)"); +is(IkiWiki::preprocess("foo", "foo", "[[!foo < $multiline)", "nested multiline strings"); + "foo(a => $multiline)", "nested multiline strings"); }