Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Convert/tester/doc
(section)
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. <pre> 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 </pre> This example provides the same results as the multiline string at "Mixed tests" above.
Summary:
Please note that all contributions to Stockhub 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
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)