<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://christianpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ACitation%2FCS1%2Ftestcases%2Fanchor</id>
	<title>Module:Citation/CS1/testcases/anchor - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://christianpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ACitation%2FCS1%2Ftestcases%2Fanchor"/>
	<link rel="alternate" type="text/html" href="http://christianpedia.com/index.php?title=Module:Citation/CS1/testcases/anchor&amp;action=history"/>
	<updated>2026-04-03T19:47:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>http://christianpedia.com/index.php?title=Module:Citation/CS1/testcases/anchor&amp;diff=368&amp;oldid=prev</id>
		<title>Admin: 1 revision imported: Add</title>
		<link rel="alternate" type="text/html" href="http://christianpedia.com/index.php?title=Module:Citation/CS1/testcases/anchor&amp;diff=368&amp;oldid=prev"/>
		<updated>2024-03-31T16:30:40Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported: Add&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:30, 31 March 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://christianpedia.com/index.php?title=Module:Citation/CS1/testcases/anchor&amp;diff=367&amp;oldid=prev</id>
		<title>Admin: remove bad tests</title>
		<link rel="alternate" type="text/html" href="http://christianpedia.com/index.php?title=Module:Citation/CS1/testcases/anchor&amp;diff=367&amp;oldid=prev"/>
		<updated>2021-04-27T03:07:20Z</updated>

		<summary type="html">&lt;p&gt;remove bad tests&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- we never call cs1 directly because it doesn&amp;#039;t have a nice implementation&lt;br /&gt;
-- as a module, so comment out below line&lt;br /&gt;
-- local myModule = require(&amp;#039;Module:Citation/CS1&amp;#039;) -- the module to be tested&lt;br /&gt;
local ScribuntoUnit = require(&amp;#039;Module:ScribuntoUnit&amp;#039;)&lt;br /&gt;
local suite = ScribuntoUnit:new()&lt;br /&gt;
&lt;br /&gt;
-- merge keys and values into one table&lt;br /&gt;
local function merge(t1, t2)&lt;br /&gt;
	local t3 = {}&lt;br /&gt;
	for k, v in pairs(t1) do&lt;br /&gt;
		t3[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	for k, v in pairs(t2) do&lt;br /&gt;
		t3[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	return t3&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Finds the citeref in an expanded CS1/2 template. Takes a test_parameters&lt;br /&gt;
-- table and a specific template invoke&amp;#039;s args. The test_parameters table has&lt;br /&gt;
-- the following fields:&lt;br /&gt;
-- * base_args, a table representing the template args common to the test case.&lt;br /&gt;
-- * pattern, a string to find in the expanded template&lt;br /&gt;
-- * frame, usually from mw.getCurrentFrame()&lt;br /&gt;
-- * template, a string which is the name of the template to test.&lt;br /&gt;
-- targs is a table of the template arguments unique to the specific assertion.&lt;br /&gt;
local function citeref(test_parameters, targs)&lt;br /&gt;
	&lt;br /&gt;
	local merged_args = merge(test_parameters.base_args, targs)&lt;br /&gt;
	local expansion = test_parameters.frame:expandTemplate{&lt;br /&gt;
		title = test_parameters.template, args = merged_args&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local _, _, citeref_value = mw.ustring.find(expansion, test_parameters.pattern)&lt;br /&gt;
	if not citeref_value then&lt;br /&gt;
		citeref_value = &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return citeref_value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Tests to ensure author masks don&amp;#039;t corrupt the CITEREF&lt;br /&gt;
function suite:testAuthorMask()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039;, year = &amp;#039;2020&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {chapter = &amp;#039;CH&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {[&amp;#039;author-mask&amp;#039;] = &amp;#039;A1&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {[&amp;#039;author-mask1&amp;#039;] = &amp;#039;2&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Tests what happens with various counts of contributors, authors, and editors&lt;br /&gt;
function suite:testCounts()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, year = &amp;#039;2020&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;&amp;#039;, citeref(env, {chapter = &amp;#039;CH&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;&amp;#039;, citeref(env, {contributor = &amp;#039;C1&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;&amp;#039;, citeref(env, {contributor = &amp;#039;C1&amp;#039;, contribution = &amp;#039;CON&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_E1_2020&amp;#039;, citeref(env, {editor = &amp;#039;_E1_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_C1_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;, contribution = &amp;#039;CON&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, editor = &amp;#039;_E1_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_E1_2020&amp;#039;, citeref(env, {editor = &amp;#039;_E1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_E1_2020&amp;#039;, citeref(env, {editor = &amp;#039;_E1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;, contribution = &amp;#039;CON&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;, editor = &amp;#039;_E1_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_C1_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;, editor = &amp;#039;_E1_&amp;#039;, contribution = &amp;#039;CON&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_A2_A3_A4_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, author2 = &amp;#039;A2_&amp;#039;, author3 = &amp;#039;A3_&amp;#039;, author4 = &amp;#039;A4_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_A2_A3_A4_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, author2 = &amp;#039;A2_&amp;#039;, author3 = &amp;#039;A3_&amp;#039;, author4 = &amp;#039;A4_&amp;#039;, author5 = &amp;#039;A5_&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_C1_C2_C3_2020&amp;#039;, citeref(env, {author = &amp;#039;_A1_&amp;#039;, contributor = &amp;#039;_C1_&amp;#039;, contributor2 = &amp;#039;C2_&amp;#039;, contributor3 = &amp;#039;C3_&amp;#039;, contribution = &amp;#039;CON&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_E1_E2_2020&amp;#039;, citeref(env, {editor = &amp;#039;_E1_&amp;#039;, editor2 = &amp;#039;E2_&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Tests date resolution code, including anchor years.&lt;br /&gt;
function suite:testDates()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {year=&amp;#039;2020&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_c\._2020&amp;#039;, citeref(env, {date=&amp;#039;c. 2020&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {date=&amp;#039;1 January 2020&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020a&amp;#039;, citeref(env, {date=&amp;#039;1 January 2020a&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {date=&amp;#039;1 January 2020&amp;#039;, year=&amp;#039;2020&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020a&amp;#039;, citeref(env, {date=&amp;#039;1 January 2020&amp;#039;, year=&amp;#039;2020a&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020&amp;#039;, citeref(env, {date=&amp;#039;2020-01-01&amp;#039;, year=&amp;#039;2020&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_2020a&amp;#039;, citeref(env, {date=&amp;#039;2020-01-01&amp;#039;, year=&amp;#039;2020a&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testDatesMaint()&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
	local base_args = {title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039;, year = &amp;#039;2020&amp;#039;}&lt;br /&gt;
	local template = &amp;#039;cite book/new&amp;#039;&lt;br /&gt;
	local maint = &amp;#039;CS1 maint: date and year&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	self:assertStringContains(maint, frame:expandTemplate{&lt;br /&gt;
		title = template, args = merge(base_args, { date = &amp;#039;1 January 2020&amp;#039;})&lt;br /&gt;
	})&lt;br /&gt;
	self:assertStringContains(maint, frame:expandTemplate{&lt;br /&gt;
		title = template, args = merge(base_args, { date = &amp;#039;2020-01-01&amp;#039;})&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- should fail: extra unexpected nd in the anchor, plus trailingauthordash below&lt;br /&gt;
-- TODO: Should that change? I&amp;#039;ve seen workarounds in the wild.&lt;br /&gt;
function suite:testDatesExtraNd()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_&amp;#039;, citeref(env, {date=&amp;#039;nd&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- should fail: extra unexpected n.d. in the anchor&lt;br /&gt;
-- TODO: Should that change? I&amp;#039;ve seen workarounds in the wild.&lt;br /&gt;
function suite:testDatesExtraNdPunct()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_&amp;#039;, citeref(env, {date=&amp;#039;n.d.&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Tests to ensure display name settings don&amp;#039;t corrupt the CITEREF&lt;br /&gt;
function suite:testDisplayNames()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039;, author2 = &amp;#039;A2_&amp;#039;, date = &amp;#039;2020&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_A2_2020&amp;#039;, citeref(env, {chapter = &amp;#039;CH&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_A2_2020&amp;#039;, citeref(env, {[&amp;#039;display-authors&amp;#039;] = &amp;#039;0&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_A2_2020&amp;#039;, citeref(env, {[&amp;#039;display-authors&amp;#039;] = &amp;#039;1&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_A2_2020&amp;#039;, citeref(env, {[&amp;#039;display-authors&amp;#039;] = &amp;#039;etal&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Tests what happens for certain values of ref&lt;br /&gt;
function suite:testRef()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;(id=\&amp;quot;CITEREF%S-\&amp;quot;)&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039;, year = &amp;#039;2020&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	-- TODO test citation for equivalent value&lt;br /&gt;
	self:assertEquals( &amp;#039;id=\&amp;quot;CITEREF_A1_2020\&amp;quot;&amp;#039;, citeref(env, {chapter = &amp;#039;CH&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;&amp;#039;, citeref(env, {ref = &amp;#039;none&amp;#039;}))&lt;br /&gt;
	self:assertEquals( &amp;#039;id=\&amp;quot;CITEREF_A1_2020\&amp;quot;&amp;#039;, citeref(env, {ref = &amp;#039;CITEREF_A1_2020&amp;#039;}))&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- slightly different setup; we want to test that the input ID is the output ID&lt;br /&gt;
function suite:testRefREF()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;(id=\&amp;quot;REF\&amp;quot;)&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039;, year = &amp;#039;2020&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;id=\&amp;quot;REF\&amp;quot;&amp;#039;, citeref(env, {ref = &amp;#039;REF&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- tests for expected presence of maintenance messages in ref&lt;br /&gt;
function suite:testRefMaint()&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
	local base_args = {title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039;, date = &amp;#039;2020&amp;#039;}&lt;br /&gt;
	&lt;br /&gt;
	self:assertStringContains(&amp;#039;CS1 maint: ref duplicates default&amp;#039;, frame:expandTemplate{&lt;br /&gt;
		title = &amp;#039;cite book/new&amp;#039;, args = merge(base_args, { ref = &amp;#039;CITEREF_A1_2020&amp;#039;})&lt;br /&gt;
	})&lt;br /&gt;
	self:assertStringContains(&amp;#039;Invalid &amp;lt;code class=\&amp;quot;cs1%-code\&amp;quot;&amp;gt;&amp;amp;#124;ref=harv&amp;lt;/code&amp;gt;&amp;#039;, frame:expandTemplate{&lt;br /&gt;
		title = &amp;#039;cite book/new&amp;#039;, args = merge(base_args, { ref = &amp;#039;harv&amp;#039;})&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- should fail: missing trailing underscore in anchor; not sure if that&amp;#039;s desirable&lt;br /&gt;
-- or if that can change&lt;br /&gt;
-- TODO: Ask someone.&lt;br /&gt;
function suite:testTrailingAuthorDash()&lt;br /&gt;
	local env = {&lt;br /&gt;
		frame = mw.getCurrentFrame(),&lt;br /&gt;
		pattern = &amp;#039;id=\&amp;quot;(CITEREF%S-)\&amp;quot;&amp;#039;,&lt;br /&gt;
		template = &amp;#039;cite book/new&amp;#039;,&lt;br /&gt;
		base_args = { title = &amp;#039;T&amp;#039;, author = &amp;#039;_A1_&amp;#039; }&lt;br /&gt;
	}&lt;br /&gt;
	self:assertEquals( &amp;#039;CITEREF_A1_&amp;#039;, citeref(env, {chapter=&amp;#039;CH&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return suite&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>