تضامنًا مع حق الشعب الفلسطيني |
وحدة:Citation/CS1/مختبر/errors
توثيق الوحدة[أنشئ] [محو الاختزان][استخدامات] [قوالب]
--[=[
Unit tests for [[Module:Citation/CS1]] error messages. This is not intended to
test every possible thing that can make an error message; rather, it is to test
the creation and rendering of the messages themselves.
Tests are displayed on the talk page alphabetically by test name. By convention,
tests for errors are all lowercase, especially after "test_" e.g. test_disp_name,
which differentiates them from maintenance messages, which have an uppercase
immediately after the "_" e.g. test_Ref_maint.
Click talk page to run tests.
]=]
local p = require('Module:UnitTests')
--[[==========================<< E R R O R M E S S A G E S >>========================================
]]
--[[--------------------------< W I K I L I N K _ I N _ U R L >------------------------------------------------
]]
function p:test_wikilink_in_url()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |journal=Journal |', '}}', '{{cite journal |journal=Journal |', '}}',
{
{'title=عنوان |url=//example.com |title-link=Title'}, -- citation0()
{'pmc=12345 |title=عنوان |url=//example.com |title-link=Title'}, -- citation0()
{'title=[[Title]] |url=//example.com'}, -- safe_for_url()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ V A U T H O R S >----------------------------------------------------
]]
function p:test_vauthors()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'vauthors=Black ABC'}, -- too many initials
{'vauthors=Black A-B'}, -- hyphenated initials
{'vauthors=Black AB II'}, -- invalid generational suffix - does not show an error but it should
{'vauthors=Black AB 3d'}, -- invalid generational suffix
{'vauthors=Black, AB, Brown, CD'}, -- improper puncutation - does not show an error but it should
{'vauthors=Black AB; Brown CD'}, -- improper puncutation
{'vauthors=Вlack AВ, Вrown CD'}, -- the 'В's are Cyrillic characters
{'vauthors=Black AB, Вrown CD'}, -- the 'В's in Brown is Cyrillic
{'vauthors=Black AB Brown CD'}, -- missing comma
{'vauthors=Black A B'}, -- spaced initials
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ V A N C O U V E R >--------------------------------------------------
]]
function p:test_vancouver()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |name-list-style=vanc |', '}}',
'{{cite book |title=عنوان |name-list-style=vanc |', '}}',
{
{'last=Black |first=AB 3d'}, -- invalid generational suffix - reduce_to_initials()
{'last=Вlack |first=Alpha Вravo'}, -- the 'В's are Cyrillic characters
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ T R A N S _ M I S S I N G _ T I T L E >------------------------------
]]
function p:test_trans_missing_title()
self:preprocess_equals_preprocess_many(
'{{cite book/new |', '}}', '{{cite book |', '}}',
{
{'trans-title=Trans Title'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ T E X T _ I G N O R E D >--------------------------------------------
]]
function p:test_text_ignored()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'text to be ignored'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ S S R N _ M I S S I N G >--------------------------------------------
]]
function p:test_ssrn_missing()
self:preprocess_equals_preprocess_many(
'{{cite ssrn/new |title=عنوان', '}}', '{{cite ssrn |title=عنوان', '}}',
{
{''},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ S C R I P T _ P A R A M E T E R >------------------------------------
]]
function p:test_script_parameter()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'script-title=ja:'}, -- missing title part
{'script-title=ac:script-title'}, -- unknown language code
{'script-title=es:script-title'}, -- invalid language code
{'script-title=script-title'}, -- missing prefix
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S >----------------------------
]]
function p:test_redundant_parameters()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'type=Type |meduim=Meduim'}, -- argument_wrapper()
{'last=Last |last1=Last1'}, -- extract_names()
{'last=Last |first=First |first1=First1'}, -- extract_names()
{'last=Last |first=First |author-mask=Author-mask |author-mask1=Author-mask1'}, -- extract_names()
{'last=Last |first=First |author-link=Author |author1-link=Author'}, -- extract_names()
{'vauthors=[[Author|Author AA]] |author-link=Author'}, -- parse_vauthors_veditors()
{'vauthors=Black AB |author2=Brown CD'}, -- select_author_editor_source()
{'page=1 |pages=3, 4'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S _ 2 >------------------------
]]
function p:test_redundant_parameters_2()
self:preprocess_equals_preprocess_many(
'{{cite mailing list/new |title=عنوان |', '}}', '{{cite mailing list |title=عنوان |', '}}',
{
{'mailing-list=Mailing list |work=work'}, -- argument_wrapper()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S _ 3 >------------------------
]]
function p:test_redundant_parameters_3()
self:preprocess_equals_preprocess_many(
'{{cite encyclopedia/new |title=عنوان |', '}}', '{{cite encyclopedia |title=عنوان |', '}}',
{
{'encyclopedia=Encyclopedia |work=work'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S _ 4 >------------------------
]]
function p:test_redundant_parameters_4()
self:preprocess_equals_preprocess_many(
'{{citation/new |title=عنوان |', '}}', '{{citation |title=عنوان |', '}}',
{
{'encyclopedia=Encyclopedia |work=work'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S _ 5 >------------------------
]]
function p:test_redundant_parameters_5()
self:preprocess_equals_preprocess_many(
'{{cite techreport/new |title=عنوان |', '}}', '{{cite techreport |title=عنوان |', '}}',
{
{'number=1 |id=ID'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S _ 6 >------------------------
]]
function p:test_redundant_parameters_6()
self:preprocess_equals_preprocess_many(
'{{cite map/new |title=عنوان |', '}}', '{{cite map |title=عنوان |', '}}',
{
{'chapter=Chapter |map=Map'}, -- citation0()
{'chapter=Chapter'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E D U N D A N T _ P A R A M E T E R S _ 7 >------------------------
]]
function p:test_redundant_parameters_7()
self:preprocess_equals_preprocess_many(
'{{cite episode/new |title=عنوان |series=Series |', '}}', '{{cite episode |title=عنوان |series=Series |', '}}',
{
{'season=Season |series-number=Series number'}, -- citation0()
{'minutes=Minutes |time=Time'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M E T E R _ I G N O R E D _ S U G G E S T >------------------
]]
function p:test_parameter_ignored_suggest()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'Chapter=Chapter'}, -- citation() - case
{'pulbisher=Pulbisher'}, -- citation() – misspelled pattern matched
{'pub=Publisher'}, -- citation() – explicit match
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M E T E R _ I G N O R E D >----------------------------------
]]
function p:test_parameter_ignored()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'unknown=unknown'}, -- citation()
{'encyclopedia=Encyclopedia'}, -- citation0() – |encyclopedia= only available in {{cite encyclopdia}} and {{citation}}
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M E T E R _ I G N O R E D _ 2 >------------------------------
]]
function p:test_parameter_ignored_2()
self:preprocess_equals_preprocess_many(
'{{cite ssrn/new |title=عنوان |ssrn=123456 |', '}}', '{{cite ssrn |title=عنوان |ssrn=123456 |', '}}',
{
{'pulbisher=Pulbisher'}, -- citation() – misspelled pattern matched but suggested param not supported by this template
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M E T E R _ I G N O R E D _ 3 >------------------------------
]]
function p:test_parameter_ignored_3()
self:preprocess_equals_preprocess_many(
'{{cite newsgroup/new |title=عنوان |', '}}', '{{cite newsgroup |title=عنوان |', '}}',
{
{'newsgroup=sommat.sommat.sommat |publisher=Publisher'}, -- citation0() - |publisher= not supported by {{cite newsgroup}}
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M _ H A S _ E X T _ L I N K >--------------------------------
]]
function p:test_param_has_ext_link()
self:preprocess_equals_preprocess_many(
'{{cite book/new |', '}}', '{{cite book |', '}}',
{
{'title=عنوان //example.com'}, -- check_for_url()
{'title=عنوان http://example.com'}, -- check_for_url()
{'title=[http://example.com Title]'}, -- check_for_url()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M _ A C C E S S _ R E Q U I R E S _ P A R A M >--------------
]]
function p:test_param_access_requires_param()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'url-access=subscription'}, -- citation0()
{'doi-access=free'}, -- extract_id_access_levels() (~/Identifiers)
{'chapter-url-access=subscription'}, -- citation0()
-- {'map-url-access=subscription'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P A R A M _ A C C E S S _ R E Q U I R E S _ P A R A M _ 2 >----------
]]
function p:test_param_access_requires_param_2()
self:preprocess_equals_preprocess_many(
'{{cite map/new |title=عنوان |', '}}', '{{cite map |title=عنوان |', '}}',
{
{'map-url-access=subscription'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ M I S S I N G _ P I P E >--------------------------------------------
]]
function p:test_missing_pipe()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |url=//example.com |', '}}', '{{cite book |title=عنوان |url=//example.com |', '}}',
{
{'chapter=Chapter access-date=2020-06-10'}, -- missing_pipe_check()
{'chapter=access-date=2020-06-10'}, -- missing_pipe_check()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ M I S S I N G _ P E R I O D I C A L >--------------------------------
]]
function p:test_missing_periodical()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان', '}}', '{{cite journal |title=عنوان', '}}',
{
{''}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ M I S S I N G _ P E R I O D I C A L _ 2 >----------------------------
]]
function p:test_missing_periodical_2()
self:preprocess_equals_preprocess_many(
'{{cite magazine/new |title=عنوان', '}}', '{{cite magazine |title=عنوان', '}}',
{
{''}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ M I S S I N G _ N A M E >--------------------------------------------
]]
function p:test_missing_name()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'author=Black AB |author3=Red EF'}, -- extract_names()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ I N V I S I B L E _ C H A R >----------------------------------------
]]
function p:test_invisible_char()
self:preprocess_equals_preprocess_many(
'{{cite book/new |', '}}', '{{cite book |', '}}',
{
{'title=عنوان\239\191\189'}, -- replacement char - has_invisible_chars()
{'title=عنوان\127UNIQ--spoof-000000-QINU\127'}, -- spoof a stripmarker so that comparison compares the same thing; <spoof></spoof> does not exist so not replaced with content
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ I N V A L I D _ P A R A M _ V A L >----------------------------------
]]
function p:test_invalid_param_val()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'mode=cs3'}, -- is_valid_parameter_value()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ F O R M A T _ M I S S I N G _ U R L >--------------------------------
]]
function p:test_format_missing_url()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'format=abc'}, -- style_format()
{'archive-format=def'},
{'chapter-format=ghi'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ F I R S T _ M I S S I N G _ L A S T >--------------------------------
]]
function p:test_first_missing_last()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'first=AB'}, -- extract_names()
{'editor-first=AB'},
{'given=AB'},
{'editor-given=AB'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ E T A L >------------------------------------------------------------
]]
function p:test_etal()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'editor=Black AB; et al'}, -- name_has_etal()
{'editor=Black AB, et al'},
{'editor=Black AB et al'},
{'editor=Black AB "et al"'},
{'editor=Black AB \'et al\''},
{'editor=Black AB et. al.'},
{'editor=Black AB ET AL'},
{'editor=Black AB EtAl'},
{'editor=Black AB, \'\'et alia.\'\''},
{'editor=Black AB; and others'},
{'editor=Black AB; [[et al]]'},
{'editor=Black AB; [et al]'},
{'editor=Black AB; (et al)'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ E M P T Y _ C I T A T I O N >----------------------------------------
]]
function p:test_empty_citation()
self:preprocess_equals_preprocess_many(
'{{cite book/new', '}}', '{{cite book', '}}',
{
{''}, -- citation()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ D O I B R O K E N _ M I S S I N G _ D O I >--------------------------
]]
function p:test_doibroken_missing_doi()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'doi-broken-date=June 2020'}, -- citation()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ D E P R E C A T E D _ P A R A M S >----------------------------------
this here for completeness; can't test deprecated param error messaging without actual deprecated parameters; at
this writing, 2020-06-10 there are no deprecated parameters
]]
function p:test_deprecated_params()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'editors'}, -- citation()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C O N T R I B U T O R _ M I S S I N G _ R E Q U I R E D _ P A R A M >
]]
function p:test_contributor_missing_required_param()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |contributor=Contributor |', '}}', '{{cite book |title=عنوان |contributor=Contributor |', '}}',
{
{'contribution=Contribution'}, -- citation0()
{'author=Author'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C O N T R I B U T O R _ I G N O R E D >------------------------------
]]
function p:test_contributor_ignored()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |contributor=Contributor |journal= Journal', '}}', '{{cite journal |title=عنوان |contributor=Contributor |journal= Journal', '}}',
{
{''}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C L A S S _ I G N O R E D >------------------------------------------
]]
function p:test_class_ignored()
self:preprocess_equals_preprocess_many(
'{{cite arXiv/new |title=عنوان |author=Author |', '}}', '{{cite arXiv |title=عنوان |author=Author |', '}}',
{
{'arxiv=abc.de/9901333 |class=abc'}, -- arxiv() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C I T E S E E R X _ M I S S I N G >----------------------------------
]]
function p:test_citeseerx_missing()
self:preprocess_equals_preprocess_many(
'{{cite citeseerx/new |', '}}', '{{cite citeseerx |', '}}',
{
{'title=عنوان '}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C I T E _ W E B _ U R L >--------------------------------------------
]]
function p:test_cite_web_url()
self:preprocess_equals_preprocess_many(
'{{cite web/new |', '}}', '{{cite web |', '}}',
{
{'title=عنوان'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C I T E _ W E B _ U R L _ 2 >----------------------------------------
]]
function p:test_cite_web_url_2()
self:preprocess_equals_preprocess_many(
'{{citation/new |', '}}', '{{citation |', '}}',
{
{'title=عنوان |website=Website'}, -- citation0()
{'title=عنوان |script-website=ja:Website'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C I T A T I O N _ M I S S I N G _ T I T L E >------------------------
]]
function p:test_citation_missing_title()
self:preprocess_equals_preprocess_many(
'{{cite book/new |', '}}', '{{cite book |', '}}',
{
{'author=Author'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C I T A T I O N _ M I S S I N G _ T I T L E _ 2 >--------------------
]]
function p:test_citation_missing_title_2()
self:preprocess_equals_preprocess_many(
'{{cite episode/new |', '}}', '{{cite episode |', '}}',
{
{'author=Author'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ C H A P T E R _ I G N O R E D >--------------------------------------
]]
function p:test_chapter_ignored()
self:preprocess_equals_preprocess_many(
'{{cite news/new |title=عنوان |', '}}', '{{cite news |title=عنوان |', '}}',
{
{'chapter=Chapter'}, -- citation0()
{'chapter-url=//example.com'}, -- citation0()
{'trans-chapter=Trans-chapter'}, -- citation0()
{'script-chapter=ja:Script-chapter'}, -- citation0()
{'chapter-format=Chapter-format'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B I O R X I V _ M I S S I N G >--------------------------------------
]]
function p:test_biorxiv_missing()
self:preprocess_equals_preprocess_many(
'{{cite bioRxiv/new |', '}}', '{{cite bioRxiv |', '}}',
{
{'title=عنوان '}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A R E _ U R L _ M I S S I N G _ T I T L E >------------------------
]]
function p:test_bare_url_missing_title()
self:preprocess_equals_preprocess_many(
'{{cite book/new |', '}}', '{{cite book |', '}}',
{
{'title=عنوان |chapter-url=//example.com'}, -- citation0()
{'title=عنوان |conference-url=//example.com'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A R E _ U R L _ M I S S I N G _ T I T L E _ 2 >--------------------
]]
function p:test_bare_url_missing_title_2()
self:preprocess_equals_preprocess_many(
'{{cite map/new |', '}}', '{{cite map |', '}}',
{
{'title=عنوان |map-url=//example.com'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ Z B L >------------------------------------------------------
]]
function p:test_bad_zbl()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'zbl=ZBL'}, -- zbl() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ U S E N E T _ I D >------------------------------------------
]]
function p:test_bad_usenet_id()
self:preprocess_equals_preprocess_many(
'{{cite newsgroup/new |title=عنوان |', '}}', '{{cite newsgroup |title=عنوان |', '}}',
{
{'message-id=message-id'}, -- usenet_id() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ U R L >------------------------------------------------------
]]
function p:test_bad_url()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'url=example.com'}, -- zbl() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ S S R N >----------------------------------------------------
]]
function p:test_bad_ssrn()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'ssrn=SSRN'}, -- ssrn() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ S B N >------------------------------------------------------
]]
function p:test_bad_sbn()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'sbn=123–456789'}, -- invalid character - sbn() (~/Identifiers)
{'sbn=12345678'}, -- improper length
{'sbn=123X45678'}, -- X in wrong spot
{'sbn=012345678'}, -- incorrect check digit
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ S 2 C I D >--------------------------------------------------
]]
function p:test_bad_s2cid()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'s2cid=S2CID'}, -- s2cid() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ O C L C >----------------------------------------------------
]]
function p:test_bad_oclc()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'oclc=OCLC'}, -- oclc() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ P M I D >----------------------------------------------------
]]
function p:test_bad_pmid()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'pmid=PMID'}, -- pmid() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ P M C >------------------------------------------------------
]]
function p:test_bad_pmc()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'pmc=PMC'}, -- pmc() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ P A R A M _ L I N K >----------------------------------------
]]
function p:test_bad_paramlink()
self:preprocess_equals_preprocess_many(
'{{cite book/new |', '}}', '{{cite book |', '}}',
{
{'title=[[Title]] |title-link=Title'}, -- link_title_ok()
{'title=عنوان |title-link=[[Title]]'}, -- link_title_ok()
{'title=عنوان |title-link=//example.com'}, -- link_title_ok()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ O L >--------------------------------------------------------
]]
function p:test_bad_ol()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'ol=OL'}, -- ol() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ M R >--------------------------------------------------------
]]
function p:test_bad_mr()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'mr=MR'}, -- mr() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ L C C N >----------------------------------------------------
]]
function p:test_bad_lccn()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'lccn=LCCN'}, -- lccn() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ J F M >------------------------------------------------------
]]
function p:test_bad_jfm()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'jfm=JFM'}, -- jfm() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ I S S N >----------------------------------------------------
]]
function p:test_bad_issn()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'issn=ISSN'}, -- issn() (~/Identifiers)
{'eissn=eISSN'}, -- issn() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ I S M N >----------------------------------------------------
]]
function p:test_bad_ismn()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'ismn=ISMN'}, -- ismn() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ I S B N >----------------------------------------------------
]]
function p:test_bad_isbn()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'isbn=0–1234567890'}, -- invalid character - ismn() (~/Identifiers)
{'isbn=01234567890X'}, -- length
{'isbn=01234X6789'}, -- X in the wrong spot
{'isbn=978-01234X6789'}, -- isbn13 is digits only
{'isbn=977-0123456789'}, -- 978 or 979 prefix only
{'isbn=979-0123456789'}, -- 9790 is ismn
{'isbn=978-0123456789'}, -- check digit
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ H D L >------------------------------------------------------
]]
function p:test_bad_hdl()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'hdl=HDL'}, -- hdl() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ D O I >------------------------------------------------------
]]
function p:test_bad_doi()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'doi=10.5555/12345678'}, -- invalid registrant - doi() (~/Identifiers)
{'doi=10.2343/1234 5678'}, -- space char in suffix
{'doi=11.2343/12345678'}, -- invalid prefix
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ D A T E >----------------------------------------------------
]]
function p:test_bad_date()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'date=DATE'}, -- citation0()
{'date=2020 |year=2019'}, -- mismatch
{'date=9201 |year=2019'}, -- mismatch with date error
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ C I T E S E E R X >------------------------------------------
]]
function p:test_bad_citeseerx()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'citeseerx=CITESEERX'}, -- citeseerx() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ B I O R X I V >----------------------------------------------
]]
function p:test_bad_biorxiv()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'biorxiv=BIORXIV'}, -- biorxiv() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ B I B C O D E >----------------------------------------------
]]
function p:test_bad_bibcode()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'bibcode=..................'}, -- length - bibcode() (~/Identifiers)
{'bibcode=0999...............'}, -- value; missing letter after year
{'bibcode=0999a..............'}, -- year < 1000
{'bibcode=0999ab&............'}, -- journal abbrev must not have '&.'
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ A S I N >----------------------------------------------------
]]
function p:test_bad_asin()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'asin=ASIN'}, -- asin() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B A D _ A R X I V >--------------------------------------------------
]]
function p:test_bad_arxiv()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'arxiv=ARXIV'}, -- arxiv() (~/Identifiers)
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A R X I V _ M I S S I N G >------------------------------------------
]]
function p:test_arxiv_missing()
self:preprocess_equals_preprocess_many(
'{{cite arXiv/new |', '}}', '{{cite arXiv |', '}}',
{
{'author=Author |title=عنوان'}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A R C H I V E _ U R L >----------------------------------------------
]]
function p:test_archive_url()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'archive-url=//web.archive.org/save/'}, -- save - archive_url_check()
{'archive-url=//liveweb.archive.org/'}, -- obsolete liveweb url
{'archive-url=//web.archive.org/2020'}, -- old form url short time stamp
{'archive-url=//web.archive.org/web/2020'}, -- new form url short time stamp
{'archive-url=//web.archive.org/20200611000000id_/'}, -- old form without path and with flag
{'archive-url=//web.archive.org/path/20200611000000id_/'}, -- new form with malformed path and with flag
{'archive-url=//web.archive.org/web/20200611000000_id/'}, -- new form with path and with malformed flag
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A R C H I V E _ M I S S I N G _ U R L >------------------------------
]]
function p:test_archive_missing_url()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'archive-url=//archive.org |archive-date=2020-06-10 |url-status=live'}, -- live - citation0()
{'archive-url=//archive.org |archive-date=2020-06-10'}, -- anything else
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A P O S T R O P H E _ M A R K U P >----------------------------------
]]
function p:test_apostrophe_markup()
self:preprocess_equals_preprocess_many(
'{{cite news/new |title=عنوان |', '}}', '{{cite news |title=عنوان |', '}}',
{
{'newspaper=\'\'Newspaper\'\''}, -- citation0()
{'publisher=\'\'\'Newspaper\'\'\''}, -- citation0()
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A C C E S S D A T E _ M I S S I N G _ U R L >------------------------
]]
function p:test_accessdate_missing_url()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |title=عنوان |journal=Journal |', '}}', '{{cite journal |title=عنوان |journal=Journal |', '}}',
{
{'access-date=2020-06-11'}, -- citation0()
{'pmc=12345 |access-date=2020-06-11'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ E X T R A _ T E X T >------------------------------------------------
]]
function p:test_extra_text()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'page=p. 35'},
{'edition=1st ed.'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ D I S P _ N A M E >--------------------------------------------------
]]
function p:test_disp_name()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'author=Author |display-authors=1'},
{'author=Author |contribution=Contribution |contributor=Contributor |display-contributors=1'},
{'editor=Editor |display-editors=1'},
{'interviewer=Interviewer |display-interviewers=1'},
{'translator=Translator |display-translators=1'},
{'author=Black AB |display-authors=etalia'}
},
{nowiki=false, templatestyles=true}
)
end
--[[==========================<< M A I N T C A T M E S S A G E S >>========================================
]]
--[[--------------------------< T E S T _ A S I N _ U S E S _ I S B N >----------------------------------------
]]
function p:test_ASIN_uses_ISBN()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'asin=412346789X'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A R C H I V E D _ C O P Y >------------------------------------------
]]
function p:test_Archived_copy()
self:preprocess_equals_preprocess_many(
'{{cite book/new |url=//example.com |archive-url=//archive.org |archive-date=2020-07-29 |', '}}', '{{cite book |url=//example.com |archive-url=//archive.org |archive-date=2020-07-29 |', '}}',
{
{'title=Archived copy'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ A U T H O R S >------------------------------------------------------
]]
function p:test_Authors()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'authors=Authors'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ B O T : U N K N O W N >----------------------------------------------
]]
function p:test_Bot_unknown()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |url=//example.com |archive-url=//archive.org |archive-date=2020-07-29 |', '}}', '{{cite book |title=عنوان |url=//example.com |archive-url=//archive.org |archive-date=2020-07-29 |', '}}',
{
{'url-status=bot: unknown'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ D A T E _ F O R M A T >----------------------------------------------
]]
function p:test_Date_format()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'date=Jun-Jul 2020'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ D A T E _ Y E A R >--------------------------------------------------
]]
function p:test_Date_year()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'date=2020 |year=2020'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ D I S C O U R A G E D _ P A R A M >----------------------------------
]]
function p:test_Discourage_param()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'url=//example.com |accessdate=2020-04-09'},
{'url=//example.com |archive-url=//archive.org |archivedate=2020-04-09'},
{'url=//example.com |archiveurl=//archive.org |archive-date=2020-04-09'},
{'author=Blue |authorlink=Blue'},
{'author=Blue |author1link=Blue'},
{'author=Blue |authorlink1=Blue'},
{'date=2021 |origyear=1921'},
},
{nowiki=false, templatestyles=true}
)
self:preprocess_equals_preprocess_many(
'{{cite episode/new |series=Series |', '}}', '{{cite episode |series=Series |', '}}',
{
{'airdate=2021'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ E M B A R G O >------------------------------------------------------
]]
function p:test_Pmc_embargo_date()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'pmc=12345 |pmc-embargo-date=1 January 2020'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ E X T R A _ P U N C T >----------------------------------------------
]]
function p:test_Extra_punct()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'last=Surname,'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ E X T R A _ T E X T _ N A M E S >------------------------------------
]]
function p:test_Extra_text_names()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'author=Author (ed)'},
{'author=Author |contribution=Contribution |contributor=Contributor (ed)'},
{'editor=Editor (ed)'},
{'interviewer=Interviewer (ed)'},
{'translator=Translator (ed)'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ I G N O R E _ I S B N _ E R R >--------------------------------------
]]
function p:test_Ignore_isbn_err()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'isbn=((978-0123456789))'}, -- check digit
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ L O C A T I O N >----------------------------------------------------
]]
function p:test_Location()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'location=Sec. 6'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ M U L T _ N A M E S >------------------------------------------------
]]
function p:test_Mult_names()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'author=Name, Name, Name'},
{'author=Author |contribution=Contribution |contributor=Name, Name, Name'},
{'editor=Name, Name, Name'},
{'interviewer=Name, Name, Name'},
{'translator=Name, Name, Name'},{'author=Name; Name'},
{'author=Author |contribution=Contribution |contributor=Name; Name'},
{'editor=Name; Name'},
{'interviewer=Name; Name'},
{'translator=Name; Name'},
{'author=Name; Name, Name'},
{'author=Name; Name, Name, Name'},
{'author=Name '},
{'author=Last, FI. MI.'},
{'last=Last |first=FI. MI.'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ N U M E R I C _ N A M E S >------------------------------------------
]]
function p:test_Numeric_names()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'author=1234'},
{'author=Author |contribution=Contribution |contributor=1234'},
{'editor=1234'},
{'interviewer=1234'},
{'translator=1234'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ O T H E R S >--------------------------------------------------------
]]
function p:test_Others()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'others=Name'},
},
{nowiki=false, templatestyles=true}
)
end
function p:test_Others_avmn()
self:preprocess_equals_preprocess_many(
'{{cite AV media/new |title=عنوان |', '}}', '{{cite AV media |title=عنوان |', '}}',
{
{'others=Name'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ P M C _ F O R M A T >------------------------------------------------
]]
function p:test_Pmc_format()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'pmc=PMC12345'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ R E F _ H A R V >----------------------------------------------------
]]
function p:test_Ref_maint()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'ref=harv'},
{'author=Example|date=2008|ref=CITEREFExample2008'}
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ U N F I T >----------------------------------------------------------
]]
function p:test_Unfit()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |url=//example.com |archive-url=//archive.org |archive-date=2020-07-29 |', '}}', '{{cite book |title=عنوان |url=//example.com |archive-url=//archive.org |archive-date=2020-07-29 |', '}}',
{
{'url-status=unfit'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ U N K N O W N _ L A N G >--------------------------------------------
]]
function p:test_Unknown_lang()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'language=Taglish'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ U N T I T L E D >----------------------------------------------------
]]
function p:test_Untitled()
self:preprocess_equals_preprocess_many(
'{{cite journal/new |journal=Journal |', '}}', '{{cite journal |journal=Journal |', '}}',
{
{'title=none'},
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< T E S T _ Z B L >--------------------------------------------------------------
]]
function p:test_Zbl()
self:preprocess_equals_preprocess_many(
'{{cite book/new |title=عنوان |', '}}', '{{cite book |title=عنوان |', '}}',
{
{'zbl=07013361'},
},
{nowiki=false, templatestyles=true}
)
end
return p