- check_macro("empty", "", "");
- check_macro("plain", plain, plain);
-
- check_macro("if1", "@if{true}{yes}{no}", "yes");
- check_macro("if2", "@if{true}{yes}", "yes");
- check_macro("if3", "@if{false}{yes}{no}", "no");
- check_macro("if4", "@if{false}{yes}", "");
- check_macro("if5", "@if{ true}{yes}", "");
-
- check_macro("and1", "@and", "true");
- check_macro("and2", "@and{true}", "true");
- check_macro("and3", "@and{false}", "false");
- check_macro("and4", "@and{true}{true}", "true");
- check_macro("and5", "@and{false}{true}", "false");
- check_macro("and6", "@and{true}{false}", "false");
- check_macro("and7", "@and{false}{false}", "false");
-
- check_macro("or1", "@or", "false");
- check_macro("or2", "@or{true}", "true");
- check_macro("or2", "@or{false}", "false");
- check_macro("or3", "@or{true}{true}", "true");
- check_macro("or4", "@or{false}{true}", "true");
- check_macro("or5", "@or{true}{false}", "true");
- check_macro("or7", "@or{false}{false}", "false");
-
- check_macro("not1", "@not{true}", "false");
- check_macro("not2", "@not{false}", "true");
- check_macro("not3", "@not{wibble}", "true");
-
- check_macro("comment1", "@#{wibble}", "");
- check_macro("comment2", "@#{comment with a\nnewline in}", "");
-
- check_macro("discard1", "@discard{wibble}", "");
- check_macro("discard2", "@discard{comment with a\nnewline in}", "");
-
- check_macro("eq1", "@eq", "true");
- check_macro("eq2", "@eq{}", "true");
- check_macro("eq3", "@eq{a}", "true");
- check_macro("eq4", "@eq{a}{a}", "true");
- check_macro("eq5", "@eq{a}{a}{a}", "true");
- check_macro("eq7", "@eq{a}{b}", "false");
- check_macro("eq8", "@eq{a}{b}{a}", "false");
- check_macro("eq9", "@eq{a}{a}{b}", "false");
- check_macro("eq10", "@eq{b}{a}{a}", "false");
-
- check_macro("ne1", "@ne", "true");
- check_macro("ne2", "@ne{}", "true");
- check_macro("ne3", "@ne{a}", "true");
- check_macro("ne4", "@ne{a}{a}", "false");
- check_macro("ne5", "@ne{a}{a}{a}", "false");
- check_macro("ne7", "@ne{a}{b}", "true");
- check_macro("ne8", "@ne{a}{b}{a}", "false");
- check_macro("ne9", "@ne{a}{a}{b}", "false");
- check_macro("ne10", "@ne{b}{a}{a}", "false");
- check_macro("ne11", "@ne{a}{b}{c}", "true");
-
- check_macro("sh1", "@shell{true}", "");
- check_macro("sh2", "@shell{echo spong}", "spong\n");
- fprintf(stderr, "expect error message from macro expander:\n");
- check_macro("sh3", "@shell{echo spong;exit 3}", "spong\n");
-
- check_macro("url1", "@urlquote{unreserved}", "unreserved");
- check_macro("url2", "@urlquote{has space}", "has%20space");
- check_macro("url3", "@urlquote{\xc0\xc1}", "%c0%c1");
-
+ check_macro("empty", "", "", 0);
+ check_macro("plain", plain, plain, 0);
+ check_macro("quote1", "@@", "@", 0);
+ check_macro("quote2", "@@@@", "@@", 0);
+ check_macro("nothing1", "@_", "", 0);
+ check_macro("nothing2", "<@_>", "<>", 0);
+
+ check_macro("if1", "@if{true}{yes}{no}", "yes", 0);
+ check_macro("if2", "@if{true}{yes}", "yes", 0);
+ check_macro("if3", "@if{false}{yes}{no}", "no", 0);
+ check_macro("if4", "@if{false}{yes}", "", 0);
+ check_macro("if5", "@if{ true}{yes}", "", 0);
+ check_macro("if6", "@if{true}{yes}@_{wible}t", "yes{wible}t", 0);
+
+ check_macro("br1", "@if(true)(yes)(no)", "yes", 0);
+ check_macro("br1", "@if[true][yes]{no}", "yes{no}", 0);
+
+ check_macro("and1", "@and", "true", 0);
+ check_macro("and2", "@and{true}", "true", 0);
+ check_macro("and3", "@and{false}", "false", 0);
+ check_macro("and4", "@and{true}{true}", "true", 0);
+ check_macro("and5", "@and{false}{true}", "false", 0);
+ check_macro("and6", "@and{true}{false}", "false", 0);
+ check_macro("and7", "@and{false}{false}", "false", 0);
+
+ check_macro("or1", "@or", "false", 0);
+ check_macro("or2", "@or{true}", "true", 0);
+ check_macro("or2", "@or{false}", "false", 0);
+ check_macro("or3", "@or{true}{true}", "true", 0);
+ check_macro("or4", "@or{false}{true}", "true", 0);
+ check_macro("or5", "@or{true}{false}", "true", 0);
+ check_macro("or7", "@or{false}{false}", "false", 0);
+
+ check_macro("not1", "@not{true}", "false", 0);
+ check_macro("not2", "@not{false}", "true", 0);
+ check_macro("not3", "@not{wibble}", "true", 0);
+
+ check_macro("comment1", "@# wibble\n", "", 0);
+ check_macro("comment2", "@# comment\nplus a line", "plus a line", 0);
+
+ check_macro("discard1", "@discard{wibble}", "", 0);
+ check_macro("discard2", "@discard{comment with a\nnewline in}", "", 0);
+
+ check_macro("eq1", "@eq", "true", 0);
+ check_macro("eq2", "@eq{}", "true", 0);
+ check_macro("eq3", "@eq{a}", "true", 0);
+ check_macro("eq4", "@eq{a}{a}", "true", 0);
+ check_macro("eq5", "@eq{a}{a}{a}", "true", 0);
+ check_macro("eq7", "@eq{a}{b}", "false", 0);
+ check_macro("eq8", "@eq{a}{b}{a}", "false", 0);
+ check_macro("eq9", "@eq{a}{a}{b}", "false", 0);
+ check_macro("eq10", "@eq{b}{a}{a}", "false", 0);
+
+ check_macro("ne1", "@ne", "true", 0);
+ check_macro("ne2", "@ne{}", "true", 0);
+ check_macro("ne3", "@ne{a}", "true", 0);
+ check_macro("ne4", "@ne{a}{a}", "false", 0);
+ check_macro("ne5", "@ne{a}{a}{a}", "false", 0);
+ check_macro("ne7", "@ne{a}{b}", "true", 0);
+ check_macro("ne8", "@ne{a}{b}{a}", "false", 0);
+ check_macro("ne9", "@ne{a}{a}{b}", "false", 0);
+ check_macro("ne10", "@ne{b}{a}{a}", "false", 0);
+ check_macro("ne11", "@ne{a}{b}{c}", "true", 0);
+
+ check_macro("sh1", "@shell{true}", "", 0);
+ check_macro("sh2", "@shell{echo spong}", "spong\n", 0);
+ fprintf(stderr, ">>> expect error message about shell command:\n");
+ check_macro("sh3", "@shell{echo spong;exit 3}", "spong\n", 0);
+
+ check_macro("url1", "@urlquote{unreserved}", "unreserved", 0);
+ check_macro("url2", "@urlquote{has space}", "has%20space", 0);
+ check_macro("url3", "@urlquote{\xc0\xc1}", "%c0%c1", 0);
+
+ check_macro("include1", "@include{t-macros-1.tmpl}",
+ "yes\n", 0);
+ check_macro("include2", "@include{t-macros-2}",
+ "wibble\n", 0);
+ fprintf(stderr, ">>> expect error message about t-macros-nonesuch:\n");
+ check_macro("include3", "<@include{t-macros-nonesuch}>",
+ "<[[cannot find 't-macros-nonesuch']]>", 0);
+ fprintf(stderr, ">>> expect error message about 'wibble':\n");
+ check_macro("badex1", "<@wibble>",
+ "<[['wibble' unknown]]>", 0);
+ fprintf(stderr, ">>> expect error message about 'if':\n");
+ check_macro("badex2", "<@if>",
+ "<[['if' too few args]]>", 0);
+ fprintf(stderr, ">>> expect error message about 'if':\n");
+ check_macro("badex3", "<@if{1}{2}{3}{4}{5}>",
+ "<[['if' too many args]]>", 0);
+
+ check_macro("dirname1", "@dirname{foo/bar}", "foo", 0);
+ check_macro("dirname2", "@dirname{foo & something/bar}",
+ "foo & something", 0);
+ check_macro("basename1", "@basename{xyzzy/plugh}", "plugh", 0);
+ check_macro("basename2", "@basename{xyzzy/a<b}", "a<b", 0);
+
+ check_macro("q1", "@q{wibble}", "wibble", 0);
+ check_macro("q2", "@q{wibble}wobble", "wibblewobble", 0);
+