Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:TaxonItalics/testcases
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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, "\n") end return result end function p:test_italicizeTaxonName() local examples = { "Below genus", { "Pinus subg. Pinus", "''Pinus <span style=\"font-style:normal;\">subg.</span> Pinus''" }, { "Pinus subgenus Pinus", "''Pinus <span style=\"font-style:normal;\">subg.</span> Pinus''" }, { "P. subg. Pinus", "''P. <span style=\"font-style:normal;\">subg.</span> Pinus''" }, { "Passiflora supersect. Tacsonia", "''Passiflora <span style=\"font-style:normal;\">supersect.</span> Tacsonia''" }, { "Pinus sect. Pinus", "''Pinus <span style=\"font-style:normal;\">sect.</span> Pinus''" }, { "Pinus section Pinus", "''Pinus <span style=\"font-style:normal;\">sect.</span> Pinus''" }, { "P. sect. Pinus", "''P. <span style=\"font-style:normal;\">sect.</span> Pinus''" }, { "Pinus subsect. Pinus", "''Pinus <span style=\"font-style:normal;\">subsect.</span> Pinus''" }, { "P. subsect. Pinus", "''P. <span style=\"font-style:normal;\">subsect.</span> Pinus''" }, { "Quercus series Virentes", "''Quercus <span style=\"font-style:normal;\">ser.</span> Virentes''" }, { "Banksia subser. Banksia", "''Banksia <span style=\"font-style:normal;\">subser.</span> Banksia''" }, { "Banksia subseries Banksia", "''Banksia <span style=\"font-style:normal;\">subser.</span> Banksia''" }, { "Lyria (Mitraelyria)", "''Lyria <span style=\"font-style:normal;\">(</span>Mitraelyria<span style=\"font-style:normal;\">)</span>''" }, "Below species", { "Acer tataricum subsp. ginnala", "''Acer tataricum <span style=\"font-style:normal;\">subsp.</span> ginnala''" }, { "Aster ericoides var. ericoides", "''Aster ericoides <span style=\"font-style:normal;\">var.</span> ericoides''" }, { "A. ericoides varietas ericoides", "''A. ericoides <span style=\"font-style:normal;\">var.</span> ericoides''" }, { "A. e. subvar. ericoides", "''A. e. <span style=\"font-style:normal;\">subvar.</span> ericoides''" }, "Hybrid symbol", { "Fragaria Γ ananassa", [[''Fragaria <span style="font-style:normal;">Γ</span> ananassa'']] }, { "Fragaria × ananassa", [[''Fragaria <span style="font-style:normal;">Γ</span> ananassa'']] }, { "Fragaria × ananassa", [[''Fragaria <span style="font-style:normal;">Γ</span> ananassa'']] }, { "Γ Sorbopyrus", [[''<span style="font-style:normal;">Γ</span> Sorbopyrus'']] }, { "Γ Sorbopyrus auricularis", [[''<span style="font-style:normal;">Γ</span> Sorbopyrus auricularis'']] }, "Already italicized", { "''Pinus'' subsp. ''Pinus''", "''Pinus'' subsp. ''Pinus''" }, { "''Pinus subsp. Pinus''", "''Pinus subsp. Pinus''" }, -- Incorrect example! { "''Pinus sylvestris''", "''Pinus sylvestris''" }, { "<i>Pinus</i> subsp. <i>Pinus</i>", "''Pinus'' subsp. ''Pinus''" }, { "<i>Pinus sylvestris</i>", "''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 <code>italicizeTaxonName</code>"] = p.test_italicizeTaxonName p.test_italicizeTaxonName = nil return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:TaxonItalics/testcases/doc
(
edit
)