Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Convert/tester/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Specifying tests== If using a testcases module (as in the [[#Testcases example|above example]]), the test text is assigned to <code>p.tests</code> before executing <code>run_tests</code>. Alternatively, the test text can be read from any page, or from any section on any page. For example, the following wikitext could be entered in a sandbox: <pre> == Mixed tests == <pre> {{convert|12|m}} 12 metres (39 ft) {{convert/sandbox|0.16|/l|2|disp=table}} align="right"|0.16\n|align="right"|0.61 {{age in days|2007|5|24|2008|4|23}} 335 --- The following line is incorrect to demonstrate a "fail". {{convert|12|m|lk=on}} 12 [[meter|metres]] (39 [[Foot|ft]]) The following line demonstrates the result when no expected text is provided. {{convert/sandbox|1|-|5|in|mm|lk=on}} </pre> </pre> Given the above, the tests can be run as shown in the [[#Running tests from any page|following section]]. Instead of specifying the tests with a multiline string, it is possible to assign a table to <code>p.tests</code> as shown in the following testcases module. <syntaxhighlight lang=lua> local tests = { -- Each test item is of form { template, expected }. { '{{convert|12|m}}', '12 metres (39 ft)' }, { '{{convert/sandbox|0.16|/l|2|disp=table}}', 'align="right"|0.16\n|align="right"|0.61' }, { '{{age in days|2007|5|24|2008|4|23}}', '335' }, { '{{convert|12|m|lk=on}}', '12 [[meter|metres]] (39 [[Foot|ft]])' }, { '{{convert/sandbox|1|-|5|in|mm|lk=on}}' }, } local p = require('Module:Convert/tester') p.tests = tests return p </syntaxhighlight> This example provides the same results as the multiline string at "Mixed tests" above.
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)