X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/bf228acd0a17dc912e51fcaf84e2d6cfa1b465b3..9e1ad9037fe4cb54fb5eeb8b3ad65c6594b1c1d4:/t/preprocess.t diff --git a/t/preprocess.t b/t/preprocess.t index e1afa4a26..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 => 14; +use Test::More tests => 34; BEGIN { use_ok("IkiWiki"); } @@ -23,12 +23,29 @@ $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)"); -is(IkiWiki::preprocess("foo", "foo", "[[foo b c \"d\"]]", 0, 0), "foo(b, c, d)"); +is(IkiWiki::preprocess("foo", "foo", "[[foo b c \"d and e=f\"]]", 0, 0), "foo(b, c, d and e=f)"); is(IkiWiki::preprocess("foo", "foo", "[[foo a=1 b c=1]]", 0, 0), "foo(a => 1, b, c => 1)"); +is(IkiWiki::preprocess("foo", "foo", "[[foo a=1 b c=1 \t\t]]", 0, 0), + "foo(a => 1, b, c => 1)", "whitespace"); +is(IkiWiki::preprocess("foo", "foo", "[[foo a=1\nb \nc=1]]", 0, 0), + "foo(a => 1, b, c => 1)", "multiline directive"); is(IkiWiki::preprocess("foo", "foo", "[[foo a=1 a=2 a=3]]", 0, 0), "foo(a => 1, a => 2, a => 3)", "dup item"); is(IkiWiki::preprocess("foo", "foo", '[[foo a="[[bracketed]]" b=1]]', 0, 0), @@ -44,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"); }