Returns a function that creates testcases for a single romanization function.

Can be used by placing the following code in the testcases module:

return require("Module:transliteration module testcases") {
	module = "module name", -- for instance, "grc-translit"; module must export a tr function
    examples = {
    	{ example1, expected1 },
        { example2, expected2, script_if_different_from_below },
        { example2, expected2, script_if_different_from_below, lang_if_different_from_below },
        -- and so on
        -- Strings may be inserted to act as subheaders in the table of results.
    },
    sc = "script_code", lang = "language_code",
    -- options, e.g. nolink = true
}

The 'module' argument may be the transliteration function itself if so desired.

Positional arguments are supported and still used. There are then four required and one optional argument. The required arguments are module, examples, sc and lang as above. The fifth and optional argument is options, which gather the options as above together.

Options:

nolink
If true, the items in the "test" column will not be linked.
func_before_link
A function to process the text before it is linked or language-tagged. It receives and should return a string. For even greater flexibilty, it is actually passed the first four field of the example. (Omitted fields will be received as nil. This returned string is then treated as the name of a page in Wiktionary, unless option nolink is set.
func_with_link
A function to process the text, including the linking and language-tagging. It receives as argument the first four fields of each example, with omitted fields being nil. It returns the string to be output in the text field.
output_display
This is the display option as passed to function equals of Module:UnitTests.

As with Module:UnitTests, the documentation page should have {{#invoke:testcases module name here|run_tests}}.


"https://si.wiktionary.org/w/index.php?title=Module:transliteration_module_testcases/documentation&oldid=26151" වෙතින් සම්ප්‍රවේශනය කෙරිණි