请输入您要查询的百科知识:

 

词条 Module:TaxonItalics/testcases
释义

local p = require('Module:UnitTests')

local function clean(input)

local orig = input

local result = input:gsub("( ?)(.-)( ?)", "%1%2%3")

result = mw.text.decode(result)

if orig ~= result then

mw.log(orig, result, "\")

end

return result

end

function p:test_italicizeTaxonName()

local examples = {

"Below genus",

{ "Pinus subg. Pinus", "Pinus subg. Pinus" },

{ "Pinus subgenus Pinus", "Pinus subg. Pinus" },

{ "P. subg. Pinus", "P. subg. Pinus" },

{ "Pinus sect. Pinus", "Pinus sect. Pinus" },

{ "Pinus section Pinus", "Pinus sect. Pinus" },

{ "P. sect. Pinus", "P. sect. Pinus" },

{ "Pinus subsect. Pinus", "Pinus subsect. Pinus" },

{ "P. subsect. Pinus", "P. subsect. Pinus" },

{ "Quercus series Virentes", "Quercus ser. Virentes" },

{ "Banksia subser. Banksia", "Banksia subser. Banksia" },

{ "Banksia subseries Banksia", "Banksia subser. Banksia" },

"Below species",

{ "Acer tataricum subsp. ginnala", "Acer tataricum subsp. ginnala" },

{ "Aster ericoides var. ericoides", "Aster ericoides var. ericoides" },

{ "A. ericoides varietas ericoides", "A. ericoides var. ericoides" },

{ "A. e. subvar. ericoides", "A. e. subvar. ericoides" },

"Hybrid symbol",

{

"Fragaria × ananassa",

normal;">× ananassa

},

{

"Fragaria × ananassa",

normal;">× ananassa

},

{

"Fragaria × ananassa",

normal;">× ananassa

},

{

"× Sorbopyrus",

normal;">× Sorbopyrus

},

{

"× Sorbopyrus auricularis",

normal;">× Sorbopyrus auricularis

},

"Already italicized",

{ "Pinus subsp. Pinus", "Pinus subsp. Pinus" },

{ "Pinus subsp. Pinus", "Pinus subsp. Pinus" }, -- Incorrect example!

{ "Pinus sylvestris", "Pinus sylvestris" },

{ "Pinus subsp. Pinus", "Pinus subsp. Pinus" },

{ "Pinus sylvestris", "Pinus sylvestris" },

"Easy examples",

{ "Pinus", "Pinus" },

{ "Pinus sylvestris", "Pinus sylvestris" },

"Incorrect strings",

{

"Fragaria vesca subsp. vesca f. semperflorens",

"Fragaria vesca subsp. vesca f. semperflorens"

},

}

local italicizeTaxonName = require "Module:TaxonItalics".italicizeTaxonName

self:iterate(examples,

function (self, input, expected)

output = clean(italicizeTaxonName(input))

--[[

if output ~= expected then

mw.log(expected, output)

end

--]]

self:equals(input, output, expected)

end)

end

p["testcases for italicizeTaxonName"] = p.test_italicizeTaxonName

p.test_italicizeTaxonName = nil

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/12 3:53:03