Difference between revisions of "Module:ConvertNumeric/testcases"
Jump to navigation
Jump to search
blackwiki>Dcoetzee (Use preprocess_equals_many) |
blackwiki>Dcoetzee (Move round tests into separate method) |
||
Line 31: | Line 31: | ||
{'5E30', 'five nonillion'}, | {'5E30', 'five nonillion'}, | ||
{'-123456789.25', 'negative one hundred twenty-three million four hundred fifty-six thousand seven hundred and eighty-nine point two five'}, | {'-123456789.25', 'negative one hundred twenty-three million four hundred fifty-six thousand seven hundred and eighty-nine point two five'}, | ||
− | + | }) | |
− | + | end | |
+ | |||
+ | function p:test_numeral_to_english_round() | ||
+ | self:preprocess_equals_many('{{#invoke:ConvertNumeric | numeral_to_english |', '}}', { | ||
{'1 | round=on', 'one'}, | {'1 | round=on', 'one'}, | ||
{'37 | round=on', 'thirty-seven'}, | {'37 | round=on', 'thirty-seven'}, |
Revision as of 20:27, 25 February 2013
Documentation for this module may be created at Module:ConvertNumeric/testcases/doc
-- Unit tests for [[Module:ConvertNumeric]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_numeral_to_english()
self:preprocess_equals_many('{{#invoke:ConvertNumeric | numeral_to_english |', '}}', {
{'0', 'zero'},
{'1', 'one'},
{' 1 ', 'one'}, -- test whitespace around number
{'1 | case=u', 'One'},
{'1 | case=U', 'One'},
{'-1', 'negative one'},
{'-1 | negative=minus', 'minus one'},
{'70', 'seventy'},
{'42', 'forty-two'},
{'123', 'one hundred and twenty-three'},
{'123 | sp=us', 'one hundred twenty-three'},
{'123 | adj=on', 'one-hundred-and-twenty-three'},
{'0.25', 'zero point two five'},
{'.25', 'zero point two five'},
{'0 | ord=on', 'zeroth'},
{'33 | ord=on', 'thirty-third'},
{'40 | ord=on', 'fortieth'},
{'5000000000 | ord=on', 'five billionth'},
{'0 | pl=on', 'zeros'},
{'76 | pl=on', 'seventy-sixes'},
{'1000000000000000000000000000001', 'one nonillion and one'},
{'1.23E3', 'one thousand two hundred and thirty'},
{'123E-4', 'zero point zero one two three'},
{'1001001001001000 | lk=on', 'one [[Orders_of_magnitude_(numbers)#1015|quadrillion]] one [[Orders_of_magnitude_(numbers)#1012|trillion]] one [[Orders_of_magnitude_(numbers)#109|billion]] one million one thousand'},
{'1001001001001000 | lk=billion,quadrillion', 'one [[Orders_of_magnitude_(numbers)#1015|quadrillion]] one trillion one [[Orders_of_magnitude_(numbers)#109|billion]] one million one thousand'},
{'5E30', 'five nonillion'},
{'-123456789.25', 'negative one hundred twenty-three million four hundred fifty-six thousand seven hundred and eighty-nine point two five'},
})
end
function p:test_numeral_to_english_round()
self:preprocess_equals_many('{{#invoke:ConvertNumeric | numeral_to_english |', '}}', {
{'1 | round=on', 'one'},
{'37 | round=on', 'thirty-seven'},
{'190 | round=on', 'two hundred'},
{'110 | round=up', 'two hundred'},
{'190 | round=down', 'one hundred'},
{'87654321 | round=on', 'ninety million'},
{'12345678 | round=on', 'twelve million'},
{'-190 | round=on', 'negative two hundred'},
{'-190 | round=up', 'negative one hundred'},
{'-110 | round=down', 'negative two hundred'},
{'0.25 | round=on', 'zero'},
{'0.5 | round=on', 'one'},
{'-0.25 | round=on', 'zero'},
{'-0.5 | round=on', 'negative one'},
{'0.01 | round=up', 'one'},
{'0.99 | round=down', 'zero'},
{'-0.01 | round=down', 'negative one'},
{'-0.99 | round=up', 'zero'},
})
end
return p