Module:Sandbox/Hellknowz/Test/testcases: Difference between revisions

Content deleted Content added
add
add
 
(27 intermediate revisions by the same user not shown)
Line 3:
function p:test_parseDate() -- Must begin with 'test'
 
self:preprocess_equals_many('{{#invoke:Sandbox/Hellknowz/Test|parseDateOutputRaw|', '|noUnstrip=yes}}', {
 
--Y
Line 17:
{ 'June 2013', '2013-06' },
{ '2013 June', '2013-06' },
{ '2013, June', '2013-06' },
{ 'August 2013', '2013-08' },
{ 'August, 2013', '2013-08' },
{ 'May 2013', '2013-05' },
{ 'Jan 2013', '2013-01' },
{ 'Dec 2013', '2013-12' },
{ 'Dec. 2013', '2013-12' },
{ 'December, 2013', '2013-12' },
{ 'June 1013', 'Invalid date/time' },
{ 'June 2113', '2113-06' },
Line 44 ⟶ 48:
{ '12 Blobember 2013', 'Unrecognized pattern' },
{ '12 Dec 2013', '2013-12-12' },
{ '12 Dec. 2013', '2013-12-12' },
{ '12 June 96', 'Unrecognized pattern' },
{ '3 May, 2013', '2013-05-03' },
{ '3rd May 2013', '2013-05-03' },
{ '3rd May, 2013', '2013-05-03' },
 
--Mdy
Line 50 ⟶ 58:
{ 'August 27, 2013', '2013-08-27' },
{ 'November 30, 2013', '2013-11-30' },
{ 'Nov. 30, 2013', '2013-11-30' },
{ 'June 32, 2013', 'Invalid date/time' },
{ 'June 31, 2013', 'Invalid date/time' },
Line 62 ⟶ 71:
{ 'Blobember 12, 2013', 'Unrecognized pattern' },
{ 'June 12, 96', 'Unrecognized pattern' },
{ 'May 3 2013', '2013-05-03' },
{ 'May 3, 2013', '2013-05-03' },
{ 'May 3rd 2013', '2013-05-03' },
{ 'May 3rd, 2013', '2013-05-03' },
 
{ '2013 May 3', '2013-05-03' },
{ '2013, May 3', '2013-05-03' },
{ '2013 3 May', '2013-05-03' },
{ '2013, 3 May', '2013-05-03' },
 
--ymd
Line 79 ⟶ 97:
{ '2013-14-12', 'Invalid date/time' },
{ '2013-00-12', 'Invalid date/time' },
{ '20132003-0511', '2013-05Unrecognized pattern' }, -- for now (ambiguous case)
{ '2003-13', 'Unrecognized pattern' }, -- for now
 
{ '2013-05', 'Unrecognized pattern' }, -- for now
{ '2013-13', 'Unrecognized pattern' }, -- for now
{ '1999-11', 'Unrecognized pattern' }, -- for now
{ '1906-08', 'Unrecognized pattern' }, -- for now
-- hms
{ '10:38:27', '10:38:27'},
Line 204 ⟶ 226:
-- hp ymd
{ '10 pm, 1973-05-01', '1973-05-01 22'},
 
{ '10:38:, May 1, 1973', 'Unrecognized pattern'},
{ '10:, May 1, 1973', 'Unrecognized pattern'},
{ '10, May 1, 1973', 'Unrecognized pattern'},
 
-- invalid
Line 226 ⟶ 252:
{ 'May 2013 - February 2014', '2013-05; 2014-02' },
{ '2013 - 2014', '2013; 2014' },
 
{ 'May 3 2013 - February 12 2014', '2013-05-03; 2014-02-12' },
{ 'May 3 - October 12 2013', '2013-05-03; 2013-10-12' },
{ 'May 3 - 12 2013', '2013-05-03; 2013-05-12' },
 
{ '3rd May 2013 - 12th February 2014', '2013-05-03; 2014-02-12' },
{ 'May 3rd, 2013 - February 12th, 2014', '2013-05-03; 2014-02-12' },
{ '3rd May - 12th October 2013', '2013-05-03; 2013-10-12' },
{ 'May 3rd - October 12th, 2013', '2013-05-03; 2013-10-12' },
{ '3rd - 12th May 2013', '2013-05-03; 2013-05-12' },
{ 'May 3rd - 12th, 2013', '2013-05-03; 2013-05-12' },
 
-- variations in dates
Line 250 ⟶ 287:
{ '2013-2014', '2013; 2014' },
{ '3 May 2013 – 12 February 2014', '2013-05-03; 2014-02-12' },
{ '3 May 2013 – 12 February 2014', '2013-05-03; 2014-02-12' },
{ '3 May 2013 – 12 February 2014', '2013-05-03; 2014-02-12' },
{ '3 May 2013 – 12 February 2014', '2013-05-03; 2014-02-12' },
{ '3 May 2013 – 12 February 2014', '2013-05-03; 2014-02-12' },
{ '3 May 2013 – 12 February 2014', '2013-05-03; 2014-02-12' },
 
Line 259 ⟶ 294:
{ '3 May', 'Incomplete date' },
{ 'May 3', 'Incomplete date' },
{ 'February 29', 'Incomplete date' }, -- can't check if 29 is valid
{ 'May', 'Incomplete date' },
{ 'October', 'Incomplete date' },
Line 282 ⟶ 318:
{ '3 May - 5 April', 'Incomplete date range' },
{ 'May 3 - April 5', 'Incomplete date range' },
{ 'February 29 - April 5', 'Incomplete date range' }, -- can't check if 29 is valid
{ 'March 3 - February 29', 'Incomplete date range' },
 
-- somethign wasn't recognized stuffempty
{ 'February 2', 2013',Empty '2013-02-02input' },
{ ' ', 'Empty input' },
 
--{ '{{Start date|2012|12|10}}', 'Has metadata template' },
--[[
--{ '{{Enddate|2013|12|10}}', 'Has metadata template' },
 
--[[
{ '3 May 2013 - 5 April 2014', '2013-05-03; 2014-04-05' },
{ '3 May 2013 - April 2014', '' },
Line 298 ⟶ 340:
 
end
 
--[[
function p:test_parseField() -- Must begin with 'test'
 
self:preprocess_equals_many('{{#invoke:Sandbox/Hellknowz/Test|parseField|', '}}', {
{ '3 May 2013', '2013-05-03' },
{ '3 May 2013<ref>Well, hello there!</ref>', '2013-05-03' },
{ '3 May 2013<ref name="hello">Well, hello there!</ref>', '2013-05-03' },
{ '3 May 2013<ref name="hello">Broken', '' },
}, { nowiki = true })
 
end
]]
 
function p:test_emitMetadata() -- Must begin with 'test'
 
self:preprocess_equals_many('{{#invoke:Sandbox/Hellknowz/Test|emitMetadata|<nowiki>', '</nowiki>|dtstart=yes|dtend=yes|noTrackingCat=yes}}', {
-- different styles
{ '3 May 2013', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span>)</span>' },
{ 'May 3, 2013', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span>)</span>' },
Line 328 ⟶ 356:
{ '12:15:04', '<span style="display:none">&#160;(<span class="dtstart">12:15:04</span>)</span>' },
{ '12:15', '<span style="display:none">&#160;(<span class="dtstart">12:15</span>)</span>' },
{ '3 May 2013 – 6 February 2014', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span> - <span class="dtend">2014-02-06</span>)</span>' },
{ '3 May – 22 June 2013', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span> - <span class="dtend">2013-06-22</span>)</span>' },
{ 'May 2013 – February 2014', '<span style="display:none">&#160;(<span class="dtstart">2013-05</span> - <span class="dtend">2014-02</span>)</span>' },
{ '2013 – 2014', '<span style="display:none">&#160;(<span class="dtstart">2013</span> - <span class="dtend">2014</span>)</span>' },
 
{ '3 May 2013 <!--Hello-->', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span>)</span>' },
}, { nowiki = true })
{ '3 May 2013 {{Flag icon|USA}}', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span>)</span>' },
{ '3 May 2013<ref>Excellent job</ref>', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span>)</span>' },
{ '<!--Don`t change to 4-->3 May 2013', '<span style="display:none">&#160;(<span class="dtstart">2013-05-03</span>)</span>' },
 
}, { nowiki = true } )
 
end
 
 
function p:test_stripFieldExtras() -- Must begin with 'test'
 
self:preprocess_equals_many('{{#invoke:Sandbox/Hellknowz/Test|outputRawStripped|<nowiki>', '</nowiki>}}', {
-- references stripping
{ '3 May 2013', '3 May 2013' },
{ '3 May 2013 ', '3 May 2013' },
{ ' 3 May 2013', '3 May 2013' },
{ ' 3 May 2013 ', '3 May 2013' },
{ '3 May 2013<ref>Well, hello there!</ref>', '3 May 2013' },
{ '3 May 2013 <ref>Well, hello there!</ref>', '3 May 2013' },
{ '3 May 2013<ref name="hello">Well, hello there!</ref>', '3 May 2013' },
{ '3 May 2013</ref>Broken', '3 May 2013</ref>Broken' }, -- opening ref causes markup errors
{ '3 May 2013<ref></ref>', '3 May 2013' },
{ '3 May 2013<ref>Well, hello there!</ref><ref>Well, hello!</ref>', '3 May 2013' },
{ '3 May 2013<ref>Well, hello there!</ref><ref>Well, hello!</ref><ref>Well well well</ref>', '3 May 2013' },
{ '3 May 2013<ref name="hello">Well,</ref><ref name="hello">..hello!</ref>', '3 May 2013' },
{ '3 May 2013<ref></ref><ref></ref>', '3 May 2013' },
{ '3 May 2013<ref name="junky"/>', '3 May 2013' },
{ '3 May 2013<ref name="junky"/><ref name="junky"/>', '3 May 2013' },
{ '3 May 2013<ref name="junky"/><ref name="junky"/><ref name="junky"/>', '3 May 2013' },
{ '3 May 2013 <ref name="junky"/>', '3 May 2013' },
{ '3 May 2013<!--don\'t add extra dates-->', '3 May 2013' },
{ '3 May 2013 <!---->', '3 May 2013' },
{ '<!--Per MOS somethng do something-->3 May 2013', '3 May 2013' },
{ '<!----> 3 May 2013', '3 May 2013' },
{ '{{Flag icon|USA}} 3 May 2013', '3 May 2013' },
{ '{{Flagicon|UK}} 3 May 2013', '3 May 2013' },
{ '{{Flagicon|UK}} {{Flag icon|USA}} 3 May 2013', '3 May 2013' },
{ '3 May 2013{{Flagicon|UK}}', '3 May 2013' },
{ '3 May 2013 {{Flagicon|UK}} {{Flag icon|USA}} ', '3 May 2013' },
{ '{{Nowrap|3 May 2013}}', '3 May 2013' },
{ '{{no break | 3 May 2013 }}', '3 May 2013' },
}
, { nowiki = true }
)
 
end
 
--[[