Module:script utilities/testcases
- පහත දැක්වෙන උපදෙස්, Module:script utilities/testcases/documentation හි පිහිටා ඇත. Module:script utilities/testcases/documentation]]. [සංස්කරණය] Categories were auto-generated by Module:documentation. [edit]
- ප්රයෝජනවත් සබැඳි: root page • root page’s subpages • සබැඳි • transclusions • tested module • sandbox
5 tests failed.
Name | Expected | Actual | |
---|---|---|---|
test_lang_t | |||
test_lang_t_sc_override | |||
test_request_script_en | <small>[script needed]</small>[[Category:Requests for native script for English terms|TEST]] | <small>[script needed]</small> | |
test_request_script_en_latn | |||
test_request_script_ja | <small>[script needed]</small>[[Category:Requests for native script for Japanese terms|TEST]] | <small>[script needed]</small> | |
test_request_script_und_hebr | <small>[Hebrew needed]</small>[[Category:Requests for Hebrew script for Undetermined terms|TEST]] | <small>[හීබෲ needed]</small> | |
test_tag_text_adds_class | |||
test_tag_text_face_bold | |||
test_tag_text_face_head | |||
test_tag_text_face_hypothetical | |||
test_tag_text_face_is_ignored_for_imag_script | <span class="Imag" lang="en">123</span> | <b class="Latn" lang="en">123</b> | |
test_tag_text_face_nil | |||
test_tag_text_face_term | |||
test_tag_text_sc | |||
test_template_rfscript | Lua error -- Parameter 1 is required. |
local ScribuntoUnit = require('Module:ScribuntoUnit')
local m_script_utilities = require('Module:script utilities')
local m_scripts = require("Module:scripts")
local m_languages = require("Module:languages")
local en, ja, und = m_languages.getByCode('en'), m_languages.getByCode('ja'), m_languages.getByCode('und')
local latn, hebr, imag = m_scripts.getByCode('Latn'), m_scripts.getByCode('Hebr'), m_scripts.getByCode('Imag')
local suite = ScribuntoUnit:new()
-- helper functions
local function tag_text(args)
return m_script_utilities.tag_text(
args.text,
args.lang or en,
args.sc or latn,
args.face,
args.class
)
end
local function lang_t(args)
local frame = mw.getCurrentFrame():newChild{ title = 'test', args = args }
return m_script_utilities.lang_t(frame:newChild{})
end
local function request_script(lang, sc)
-- Make [[Module:utilities/format categories]] think that it is being
-- executed on a mainspace page so that it will output categories.
local old = mw.title.getCurrentTitle
mw.title.getCurrentTitle = function() return mw.title.new("test") end
local ret = m_script_utilities.request_script(lang, sc)
mw.title.getCurrentTitle = old
return ret
end
local function template_rfscript(args)
local frame = mw.getCurrentFrame():newChild{ title = 'test', args = args }
return m_script_utilities.template_rfscript(frame)
end
-- lang_t
function suite:test_lang_t()
local result = lang_t{'en', '123'}
suite:assertEquals('<span class="None" lang="en">123</span>', result)
end
function suite:test_lang_t_sc_override()
local result = lang_t{'ro', 'абвг', sc = 'Hani'}
suite:assertEquals('<span class="Hani" lang="ro">абвг</span>', result)
end
-- tag_text
function suite:test_tag_text_face_nil()
local result = tag_text { text='123' }
suite:assertEquals('<span class="Latn" lang="en">123</span>', result)
end
function suite:test_tag_text_face_term()
local result = tag_text { text='123', face='term' }
suite:assertEquals('<i class="Latn mention" lang="en">123</i>', result)
end
function suite:test_tag_text_face_head()
local result = tag_text { text='123', face='head' }
suite:assertEquals('<strong class="Latn headword" lang="en">123</strong>', result)
end
function suite:test_tag_text_face_hypothetical()
local result = tag_text { text='123', face='hypothetical' }
suite:assertEquals('<span class="hypothetical-star">*</span><i class="Latn hypothetical" lang="en">123</i>', result)
end
function suite:test_tag_text_face_bold()
local result = tag_text { text='123', face='bold' }
suite:assertEquals('<b class="Latn" lang="en">123</b>', result)
end
function suite:test_tag_text_sc()
local result = tag_text { text='123', sc=hebr }
suite:assertEquals('<span class="Hebr" lang="en">123</span>', result)
end
function suite:test_tag_text_face_is_ignored_for_imag_script()
local result = tag_text { text='123', face='bold', sc=imag }
suite:assertEquals('<span class="Imag" lang="en">123</span>', result)
end
function suite:test_tag_text_adds_class()
local result = tag_text { text='123', class='test' }
suite:assertEquals('<span class="Latn test" lang="en">123</span>', result)
end
-- request_script
function suite:test_request_script_en()
local result = request_script(en)
suite:assertEquals('<small>[script needed]</small>[[Category:Requests for native script for English terms|TEST]]', result)
end
function suite:test_request_script_en_latn()
local result = request_script(en, latn)
suite:assertEquals('', result)
end
function suite:test_request_script_und_hebr()
local result = request_script(und, hebr)
suite:assertEquals('<small>[Hebrew needed]</small>[[Category:Requests for Hebrew script for Undetermined terms|TEST]]', result)
end
function suite:test_request_script_ja()
local result = request_script(ja)
suite:assertEquals('<small>[script needed]</small>[[Category:Requests for native script for Japanese terms|TEST]]', result)
end
-- template_rfscript
function suite:test_template_rfscript()
local result = template_rfscript {'en'}
suite:assertEquals('<small>[script needed]</small>[[Category:Requests for native script for English terms|TEST]]', result)
end
return suite