Module:Person date/testcases
| This is the test cases page for the module Module:Person date. Results of the test cases. |
-- Unit tests for [[Module:Person date]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local Date = require('Module:Date')._Date
local today = Date('currentdate')
local current_month_past_year = os.date('%B')..' '.. os.date('%Y') - 5
local boundary_year = os.date('%Y') - 131
local this_month = today:text('%B %-Y')
local year = '1990'
local year_month = 'December 1992'
function p:test_birth_with_disap_date()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date=Nov 1990|disappeared_date=August 2020'},
{'birth_date=12 Nov 1985|disappeared_date=12 January 2020'},
{'birth_date=1990|disappeared_date={{Disappeared date and age|1920|4|1|1870}}'},
{'birth_date=12 Nov 1985|disappeared_date='},
}, {nowiki = 1})
end
function p:test_birth_only()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date='..year},
{'birth_date='..boundary_year},
{'birth_date='..year_month},
{'birth_date='..current_month_past_year},
{'birth_date=NOT A DATE'},
{'birth_date=Nov 2020'},
{'birth_date=Apr. 2022'},
{'birth_date=May '..boundary_year},
{'birth_date= 12 April 1990'}, --Intentionally leaving extra spaces
{'birth_date=Nov 12, 1989 '}, --Intentionally leaving extra spaces
{'birth_date= '},
{'birth_date=10 April '..boundary_year},
{'birth_date=1956 (age 68–69)'},
{'birth_date={{birth date and age|1990|8|2}}'},
{'birth_date={{b-da|July 7, 1987}}'},
{'birth_date={{circa|1650}}'},
{'birth_date={{approx}} 1790'},
{'birth_date=circa 1492'},
{'birth_date=1990 or 91'}
}, {nowiki = 1})
end
function p:test_unknown_birth()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date=Unknown'},
{'birth_date=Unk'},
{'birth_date=?'},
{'birth_date=?? November 2020'},
{'birth_date=unknown'}
}, {nowiki = 1})
end
function p:test_unknown_death()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|death|', '}}', '{{#invoke:person date|death|', '}}',
{
{'birth_date=10 November 1990|death_date=Unknown'},
{'birth_date=2020|death_date=Unk'},
{'birth_date=?|death_date=?'},
{'birth_date=March 1990|death_date=?? November 2020'},
{'birth_date=unknown|death_date=unknown'}
}, {nowiki = 1})
end
function p:test_birth_with_death()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date=|death_date='},
{'birth_date= |death_date= '},
{'birth_date=?|death_date=?'},
{'birth_date= 1990 |death_date= 2020 '},--Intentionally leaving extra spaces
{'birth_date=Jan 1983|death_date=2012'},
{'birth_date=October 1965|death_date=Nov 2015'},
{'birth_date=Nov 7, 1993|death_date=Nov 25, 2014'},
{'birth_date=November 7, 1993|death_date=December 12, 2014'},
{'birth_date=7 Nov 1993|death_date=8 Apr 1995'},
{'birth_date=7 November 1993|death_date=8 April 1995'}
}, {nowiki = 1})
end
function p:test_death_only()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|death|', '}}', '{{#invoke:person date|death|', '}}',
{
{'birth_date= |death_date= 2020 '}, --Intentionally leaving extra spaces
{'birth_date=|death_date=2025'},
{'birth_date=|death_date=1890'},
{'birth_date=|death_date=May 2020'},
{'birth_date=|death_date=Oct. 2020'},
{'birth_date=|death_date=15 Nov 2020'},
{'birth_date=|death_date=Nov 15, 2020'},
}, {nowiki = 1})
end
function p:test_birth_unknown_death()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date=5 October 2008|death_date=Unknown'},
{'birth_date=September 12, 2002|death_date=Unknown'},
{'birth_date=October 1990|death_date=Unknown'},
{'birth_date=2004|death_date=Unknown'},
{'birth_date={{birth year|1990}}|death_date=Unknown'},
{'birth_date={{birth date|2020|11|7}}|death_date=Unknown'}
}, {nowiki = 1})
end
function p:test_death_unknown_birth()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|death|', '}}', '{{#invoke:person date|death|', '}}',
{
{'birth_date=?|death_date=5 October 2008'},
{'birth_date=Unk|death_date=5 October 2008'},
{'birth_date=Unknown|death_date=5 October 2008'},
{'birth_date=Unknown|death_date=September 12, 2002'},
{'birth_date=Unknown|death_date=October 1990'},
{'birth_date=Unknown|death_date=2004'},
{'birth_date=Unknown|death_date={{death year|1990}}'},
{'birth_date=Unknown|death_date={{death date|2020|11|7}}'}
}, {nowiki = 1})
end
function p:test_death_ordinals()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|death|', '}}', '{{#invoke:person date|death|', '}}',
{
{'birth_date=5 October 2008|death_date=15th Nov 2020'},
{'birth_date=5 October 2008|death_date=November 15th, 2020'},
{'birth_date=5 October 2008|death_date=1st December 2020'},
{'birth_date=5 October 2008|death_date=December 1st, 2020'},
{'birth_date=5 October 2008|death_date=3rd April 2022'},
{'birth_date=5 October 2008|death_date=April 3rd, 2022'},
{'birth_date=5 October 2008|death_date=2nd May 2022'},
{'birth_date=5 October 2008|death_date=May 2nd, 2022'},
}, {nowiki = 1})
end
function p:test_birth_ordinals()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date=15th Nov 2020'},
{'birth_date=November 15th, 2020'},
{'birth_date=1st December 2020'},
{'birth_date=December 1st, 2020'},
{'birth_date=3rd April 2022'},
{'birth_date=April 3rd, 2022'},
{'birth_date=2nd May 2022'},
{'birth_date=May 2nd, 2022'},
}, {nowiki = 1})
end
function p:test_death_with_birth()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|death|', '}}', '{{#invoke:person date|death|', '}}',
{
{'birth_date=|death_date='},
{'birth_date= |death_date= '},
{'birth_date=?|death_date=?'},
{'birth_date=1990|death_date=2020'},
{'birth_date=1790|death_date=2020'},
{'birth_date=1890|death_date=2025'},
{'birth_date=1986|death_date='..current_month_past_year},
{'birth_date=Jan 1983|death_date=2012'},
{'birth_date=1965|death_date=Nov 2015'},
{'birth_date=1805|death_date=January 1856'},
{'birth_date=unknown|death_date=Nov 2015'},
{'birth_date=October 1965|death_date= Nov 2015 '}, --Intentionally leaving extra spaces
{'birth_date=April 1665|death_date=Nov 2015'},
{'birth_date= Nov 7, 1993 |death_date= Nov 25, 2014 '}, --Intentionally leaving extra spaces
{'birth_date=1993|death_date=Nov 25, 2014'},
{'birth_date=1853|death_date=Nov 25, 2014'},
{'birth_date=Dec 1993|death_date=Nov 25, 2014'},
{'birth_date=25 Jan 1914|death_date=2014'},
{'birth_date=November 7, 1993|death_date=December 12, 2014'},
{'birth_date=7 Nov 1693|death_date=8 Apr 1995'},
{'birth_date=7 Nov 1993|death_date=8 Apr 1995'},
{'birth_date=7 November 1993|death_date=8 April 1995'},
{'birth_date={{bda|1993|11|7}}|death_date=8 April 1995'},
{'birth_date=Unknown|death_date=1995'},
{'birth_date=Unknown|death_date=8 April 1995'},
{'birth_date=1960s|death_date=8 April 1995'},
}, {nowiki = 1})
end
function p:test_birth_with_reference()
self:preprocess_equals_preprocess_many('{{#invoke:person date/sandbox|birth|', '}}', '{{#invoke:person date|birth|', '}}',
{
{'birth_date=1990{{cn}}'},
{'birth_date=1995 {{cn}}'},
{'birth_date=5 October 1986{{cn}}'},
{'birth_date=5 October 1986 {{cn}}'},
{'birth_date=5 October 1986<ref name="someref">{{Cite web |title= Some website }}</ref>'}
}, {nowiki = 1, stripmarker = 1})
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.