Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 

















Module:TaxonItalics/testcases







Add links
 









Module
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 

< Module:TaxonItalics

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 &times; ananassa",
   [[''Fragaria <span style="font-style:normal;">×</span> ananassa'']]
  },
  {
   "Fragaria &#215; 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

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:TaxonItalics/testcases&oldid=1048157244"

Category: 
Module test cases
 



This page was last edited on 4 October 2021, at 15:36 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki