Module:Citation/CS1/testcases/errors
< Module:Citation | CS1 | testcases
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Citation/CS1/testcases/errors/doc
--[=[ 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=Title |url=https://example.com |title-link=Title'}, -- citation0() {'pmc=12345 |title=Title |url=https://example.com |title-link=Title'}, -- citation0() {'title=[[Title]] |url=https://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=Title |', '}}', '{{cite book |title=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=Title |name-list-style=vanc |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title', '}}', '{{cite ssrn |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite mailing list |title=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=Title |', '}}', '{{cite encyclopedia |title=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=Title |', '}}', '{{citation |title=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=Title |', '}}', '{{cite techreport |title=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=Title |', '}}', '{{cite map |title=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=Title |series=Series |', '}}', '{{cite episode |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |ssrn=123456 |', '}}', '{{cite ssrn |title=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=Title |', '}}', '{{cite newsgroup |title=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=Title //example.com'}, -- check_for_url() {'title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite map |title=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=Title |url=https://example.com |', '}}', '{{cite book |title=Title |url=https://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=Title', '}}', '{{cite journal |title=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=Title', '}}', '{{cite magazine |title=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=Title |', '}}', '{{cite book |title=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=Title\239\191\189'}, -- replacement char - has_invisible_chars() {'title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |contributor=Contributor |', '}}', '{{cite book |title=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=Title |contributor=Contributor |journal= Journal', '}}', '{{cite journal |title=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=Title |author=Author |', '}}', '{{cite arXiv |title=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=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=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=Title |website=Website'}, -- citation0() {'title=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=Title |', '}}', '{{cite news |title=Title |', '}}', { {'chapter=Chapter'}, -- citation0() {'chapter-url=https://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=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=Title |chapter-url=https://example.com'}, -- citation0() {'title=Title |conference-url=https://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=Title |map-url=https://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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite newsgroup |title=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=Title |', '}}', '{{cite book |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite book |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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 |title-link=[[Title]]'}, -- link_title_ok() {'title=Title |title-link=https://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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite book |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite book |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=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=Title |', '}}', '{{cite book |title=Title |', '}}', { {'archive-url=https://web.archive.org/save/'}, -- save - archive_url_check() {'archive-url=https://liveweb.archive.org/'}, -- obsolete liveweb url {'archive-url=https://web.archive.org/2020'}, -- old form url short time stamp {'archive-url=https://web.archive.org/web/2020'}, -- new form url short time stamp {'archive-url=https://web.archive.org/20200611000000id_/'}, -- old form without path and with flag {'archive-url=https://web.archive.org/path/20200611000000id_/'}, -- new form with malformed path and with flag {'archive-url=https://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=Title |', '}}', '{{cite book |title=Title |', '}}', { {'archive-url=https://archive.org |archive-date=2020-06-10 |url-status=live'}, -- live - citation0() {'archive-url=https://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=Title |', '}}', '{{cite news |title=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=Title |journal=Journal |', '}}', '{{cite journal |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=https://example.com |archive-url=https://archive.org |archive-date=2020-07-29 |', '}}', '{{cite book |url=https://example.com |archive-url=https://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=Title |', '}}', '{{cite book |title=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=Title |url=https://example.com |archive-url=https://archive.org |archive-date=2020-07-29 |', '}}', '{{cite book |title=Title |url=https://example.com |archive-url=https://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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=Title |', '}}', { {'url=https://example.com |accessdate=2020-04-09'}, {'url=https://example.com |archive-url=https://archive.org |archivedate=2020-04-09'}, {'url=https://example.com |archiveurl=https://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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=Title |', '}}', { {'others=Name'}, }, {nowiki=false, templatestyles=true} ) end function p:test_Others_avmn() self:preprocess_equals_preprocess_many( '{{cite AV media/new |title=Title |', '}}', '{{cite AV media |title=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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=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=Title |url=https://example.com |archive-url=https://archive.org |archive-date=2020-07-29 |', '}}', '{{cite book |title=Title |url=https://example.com |archive-url=https://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=Title |', '}}', '{{cite book |title=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=Title |', '}}', '{{cite book |title=Title |', '}}', { {'zbl=07013361'}, }, {nowiki=false, templatestyles=true} ) end return p