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