Difference between revisions of "Module:ConvertNumeric/testcases"
Jump to navigation
Jump to search
blackwiki>Dcoetzee |
blackwiki>Dcoetzee (Simplify) |
||
Line 4: | Line 4: | ||
function p:test_numeral_to_english() | function p:test_numeral_to_english() | ||
− | local | + | local cases = { |
− | + | {'0', 'zero'}, | |
− | + | {'1', 'one'}, | |
− | + | {' 1 ', 'one'}, -- test whitespace around number | |
− | + | {'-1', 'negative one'}, | |
− | + | {'-1 | negative=minus', 'minus one'}, | |
− | + | {'70', 'seventy'}, | |
− | + | {'42', 'forty-two'}, | |
− | + | {'33 | ord=on', 'thirty-third'}, | |
− | + | {'40 | ord=on', 'fortieth'}, | |
− | + | {'76 | pl=on', 'seventy-sixes'}, | |
− | + | {'-123456789.25 ', 'negative one hundred twenty-three million four hundred fifty-six thousand seven hundred and eighty-nine point two five'}, | |
+ | } | ||
+ | for i, case in ipairs(cases) do | ||
+ | self:preprocess_equals('{{#invoke:ConvertNumeric | numeral_to_english |' .. case[1] .. '}}', case[2]) | ||
+ | end | ||
end | end | ||
function p.run_tests(frame) return p:run(frame) end | function p.run_tests(frame) return p:run(frame) end | ||
return p | return p |
Revision as of 00:35, 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 UnitTests = require('Module:UnitTests')
local p = UnitTests.UnitTester:new()
function p:test_numeral_to_english()
local cases = {
{'0', 'zero'},
{'1', 'one'},
{' 1 ', 'one'}, -- test whitespace around number
{'-1', 'negative one'},
{'-1 | negative=minus', 'minus one'},
{'70', 'seventy'},
{'42', 'forty-two'},
{'33 | ord=on', 'thirty-third'},
{'40 | ord=on', 'fortieth'},
{'76 | pl=on', 'seventy-sixes'},
{'-123456789.25 ', 'negative one hundred twenty-three million four hundred fifty-six thousand seven hundred and eighty-nine point two five'},
}
for i, case in ipairs(cases) do
self:preprocess_equals('{{#invoke:ConvertNumeric | numeral_to_english |' .. case[1] .. '}}', case[2])
end
end
function p.run_tests(frame) return p:run(frame) end
return p