Template:unit-test-equals/documentation

Usage
This template is for writing "unit-tests"; see [[Template:he-adj/helper/unit-tests]] (the "unit-test" page for ) for an example. It just compares   to    and makes sure that they're equal. If so, you get something like this:



and if not, you get something like this:



and the page is added to Category:Unit test failures, unless   is set to something non-blank.

Some notes:
 * Unfortunately, it won't work if the parameters evaluate to wiki-text containing &lt;nowiki&gt;&hellip;&lt;/nowiki&gt; or &lt;nowiki/&gt;, since MediaWiki implements those via an intermediate step that replaces the whole thing with something like ~UNIQ3c52e5057596f478-nowiki-00000002-QINU~. If desired, this can generally be worked around by manually escaping whatever needed to be escaped.
 * To maximize testability, all instances of   can be replaced with    (and likewise for other such magic words), allowing a unit-test page to "pretend" that it's on a different page by passing a <tt>PAGENAME=</tt> parameter.
 * If the page-name contains an apostrophe, then <tt> </tt> will contain <tt>&amp;#39;</tt>, so templates that do sophisticated things with <tt>  </tt> should be tested with <tt> PAGENAME= </tt> (or whatnot) to make sure they behave as expected in that case.
 * This is a very strict equality test. Even something as minor as one internal space vs. two internal spaces will trigger a "unit-test" "failure", even though that's a non-semantic difference that HTMLtidy will remove anyway. If a "unit-test" "fails" and you can't figure out why, it may help to try something like <tt> </tt> so that every single byte becomes explicitly visible and you can see where the difference is.
 * If a page of unit-tests is transcluded onto other pages (e.g. using ), then you probably only want the unit-test page itself to appear in Category:Unit test failures. To that end, you can pass in <tt>nocat=&lt;includeonly&gt;1&lt;/includeonly&gt;</tt>.