Module:DateI18n/testcases: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local Date = require('Module:DateI18n')._Date-- the module to be tested local ScribuntoUnit = require('Module:ScribuntoUnit') local suite = ScribuntoUnit:new() function suit...") |
m (1 revision imported) |
(No difference)
|
Latest revision as of 15:26, 12 July 2020
Module:DateI18n
Template:Cross3 tests failed.
Name | Expected | Actual | |
---|---|---|---|
Template:Tick | test_01_English | ||
Template:Tick | test_02_French | ||
Template:Tick | test_03_Catalan | ||
Template:Tick | test_04_Gallic | ||
Template:Tick | test_05_Basque | ||
Template:Tick | test_06_Thai_solar_calendar | ||
Template:Tick | test_07_Quechua | ||
Template:Cross | test_10_YMD_in_50_languages | 2010 шаран 9 январь | 2010 шeран 9 январь |
Template:Cross | test_11_YMDHMS | 3. septembra 1569 ob 20:17:40 | 3. september 1569 ob 20:17:40 |
Template:Cross | test_12_YMDHM | 3. septembra 1569 ob 20:17 | 3. september 1569 ob 20:17 |
Template:Tick | test_gramatical_cases | ||
Template:Tick | test_outer_function | ||
Template:Tick | test_timezones | ||
Template:Tick | test_year_trimming |
local Date = require('Module:DateI18n')._Date-- the module to be tested local ScribuntoUnit = require('Module:ScribuntoUnit') local suite = ScribuntoUnit:new() function suite:test_01_English() self:assertEquals( '20 July 1969, 20:17:40', Date({1969,07,20,20,17,40},'en')) self:assertEquals( '20 July 1969, 20:17', Date({1969,07,20,20,17},'en')) self:assertEquals( '20 July 1969', Date({1969,07,20,20},'en')) self:assertEquals( '20 July 1969', Date({1969,07,20},'en')) self:assertEquals( '20 July 1969', Date({1969,07,20,nil,17,40},'en')) self:assertEquals( 'July 1969', Date({1969,07},'en')) self:assertEquals( '1969', Date({1969},'en')) self:assertEquals( '1969', Date({1969,'','','','',''},'en')) self:assertEquals( '20 July', Date({nil,07,20},'en')) self:assertEquals( 'July', Date({nil,07},'en')) end function suite:test_02_French() self:assertEquals( '1<sup>er</sup> juin 1999', Date({1999,6,1},'fr')) self:assertEquals( '2 juin 1999', Date({1999,6,2},'fr')) self:assertEquals( '1<sup>er</sup> mai', Date({'',5,1},'fr')) self:assertEquals( '2 mai', Date({'',5,2},'fr')) end function suite:test_03_Catalan() self:assertEquals( '1r de juny de 1999', Date({1999,6,1},'ca')) self:assertEquals( '2 de juny de 1999', Date({1999,6,2},'ca')) self:assertEquals( '1r de maig', Date({'',5,1},'ca')) self:assertEquals( '2 de maig', Date({'',5,2},'ca')) end function suite:test_04_Gallic() self:assertEquals( '1<sup>ú</sup> Meitheamh 1999', Date({1999,6,1},'ga')) self:assertEquals( '2 Meitheamh 1999', Date({1999,6,2},'ga')) self:assertEquals( '1<sup>ú</sup> Bealtaine', Date({'',5,1},'ga')) self:assertEquals( '2 Bealtaine', Date({'',5,2},'ga')) end function suite:test_05_Basque() self:assertEquals( '1999ko uztailaren 1ea', Date({1999,7,01},'eu')) self:assertEquals( '1999ko uztailaren 2a', Date({1999,7,02},'eu')) self:assertEquals( '1999ko uztailaren 11', Date({1999,7,11},'eu')) self:assertEquals( '1999ko uztailaren 21ea', Date({1999,7,21},'eu')) self:assertEquals( '1999ko uztailaren 31', Date({1999,7,31},'eu')) end function suite:test_06_Thai_solar_calendar() self:assertEquals( '1 มกราคม พ.ศ. 2484', Date({1941,1,1},'th')) self:assertEquals( 'มกราคม พ.ศ. 2484', Date({1941,1},'th')) --self:assertEquals( 'กันยายน พ.ศ. 2483', Date({1940,12},'th')) self:assertEquals( 'กันยายน พ.ศ. 2484', Date({1941,09},'th')) self:assertEquals( 'พ.ศ. 2484', Date({1941},'th')) self:assertEquals( '2482 หรือ 2483', Date({1940},'th')) end function suite:test_07_Quechua() self:assertEquals( '9 ñiqin inirupi 2009 watapi', Date({2009,1,9},'qu')) self:assertEquals( '9 ñiqin inirupi', Date({nil,1,9},'qu')) self:assertEquals( 'inirupi 2009 watapi', Date({2009,1},'qu')) self:assertEquals( 'iniru 2009 watapi', Date({2009,1},'qu','nom')) end function suite:test_10_YMD_in_50_languages() local datevec = {2010,1,9} self:assertEquals( '9 студзеня 2010', Date(datevec,'be')) self:assertEquals( '9 студзеня 2010', Date(datevec,'be-tarsk')) self:assertEquals( '9 студзеня 2010', Date(datevec,'be-x-old')) self:assertEquals( '৯ জানুয়ারি ২০১০', Date(datevec,'bn')) self:assertEquals( 'জানুয়ারী ৯, মারি ২০১০', Date(datevec,'bpy')) self:assertEquals( '9 de gener de 2010', Date(datevec,'ca')) self:assertEquals( '2010 шаран 9 январь', Date(datevec,'ce')) self:assertEquals( '٩ی کانوونی دووەمی ٢٠١٠', Date(datevec,'ckb')) self:assertEquals( '9. ledna 2010', Date(datevec,'cs')) self:assertEquals( '9. januar 2010', Date(datevec,'da')) self:assertEquals( '9. Januar 2010', Date(datevec,'de')) self:assertEquals( '9 Ιανουαρίου 2010', Date(datevec,'el')) self:assertEquals( '9 January 2010', Date(datevec,'en')) self:assertEquals( 'la 9-a de januaro 2010', Date(datevec,'eo')) self:assertEquals( '9 de enero de 2010', Date(datevec,'es')) self:assertEquals( '9. jaanuar 2010', Date(datevec,'et')) self:assertEquals( '2010ko urtarrilaren 9a', Date(datevec,'eu')) self:assertEquals( '‏۹ ژانویهٔ ۲۰۱۰‏', Date(datevec,'fa')) self:assertEquals( '9. tammikuuta 2010', Date(datevec,'fi')) self:assertEquals( '9 janvier 2010', Date(datevec,'fr')) self:assertEquals( '9 Eanáir 2010', Date(datevec,'ga')) self:assertEquals( '9 de xaneiro de 2010', Date(datevec,'gl')) self:assertEquals( '‏9 בינואר 2010‏', Date(datevec,'he')) self:assertEquals( '९ जनवरी २०१०', Date(datevec,'hi')) self:assertEquals( '9. siječnja 2010.', Date(datevec,'hr')) self:assertEquals( '9. januara 2010', Date(datevec,'hsb')) self:assertEquals( '2010. január 9.', Date(datevec,'hu')) self:assertEquals( '9 de januario 2010', Date(datevec,'ia')) self:assertEquals( '9. janúar 2010', Date(datevec,'is')) self:assertEquals( '2010年1月9日', Date(datevec,'ja')) self:assertEquals( 'ಜನವರಿ ೯, ೨೦೧೦', Date(datevec,'kn')) self:assertEquals( '2010년 1월 9일', Date(datevec,'ko')) self:assertEquals( '2010 m. sausio 9 d.', Date(datevec,'lt')) self:assertEquals( '2010. gada 9. janvāris', Date(datevec,'lv')) self:assertEquals( '9 јануари 2010', Date(datevec,'mk')) self:assertEquals( '9 ജനുവരി 2010', Date(datevec,'ml')) self:assertEquals( 'जानेवारी ९, इ.स. २०१०', Date(datevec,'mr')) self:assertEquals( 'ज्यानुवरी ९, ई सं २०१०', Date(datevec,'new')) self:assertEquals( '9. januar 2010', Date(datevec,'nn')) self:assertEquals( '9. januar 2010', Date(datevec,'no')) self:assertEquals( '9 de genièr de 2010', Date(datevec,'oc')) self:assertEquals( '9 ਜਨਵਰੀ 2010',Date(datevec,'pa')) self:assertEquals( '9 stycznia 2010', Date(datevec,'pl')) self:assertEquals( '9 de janeiro de 2010', Date(datevec,'pt')) self:assertEquals( '9 ñiqin inirupi 2010 watapi', Date(datevec,'qu')) self:assertEquals( '9 niki Kamaypi 2010 watapi', Date(datevec,'qug')) self:assertEquals( '9 января 2010', Date(datevec,'ru')) self:assertEquals( '9. januára 2010', Date(datevec,'sk')) self:assertEquals( '9. januarja 2010', Date(datevec,'sl')) self:assertEquals( '9. јануар 2010.', Date(datevec,'sr')) self:assertEquals( '9 มกราคม พ.ศ. 2553', Date(datevec,'th')) self:assertEquals( '9 січня 2010', Date(datevec,'uk')) self:assertEquals( '9 tháng 1 năm 2010', Date(datevec,'vi')) self:assertEquals( '2010年1月9日', Date(datevec,'zh-hans')) end function suite:test_11_YMDHMS() local datevec = {1569,09,3,20,17,40} self:assertEquals( '3 September 1569, 20:17:40', Date(datevec,'en')) self:assertEquals( '1569ko irailaren 3a, 20:17:40', Date(datevec,'eu')) self:assertEquals( '٣ی ئەیلوولی ١٥٦٩، ٢٠:١٧:٤٠', Date(datevec,'ckb')) self:assertEquals( '3. septembra 1569 ob 20:17:40', Date(datevec,'sl')) self:assertEquals( '3 tháng 9 năm 1569 lúc 20:17:40', Date(datevec,'vi')) end function suite:test_12_YMDHM() local datevec = {1569,09,3,20,17} self:assertEquals( '3 September 1569, 20:17', Date(datevec,'en')) self:assertEquals( '1569ko irailaren 3a, 20:17', Date(datevec,'eu')) self:assertEquals( '٣ی ئەیلوولی ١٥٦٩، ٢٠:١٧', Date(datevec,'ckb')) self:assertEquals( '3. septembra 1569 ob 20:17', Date(datevec,'sl')) self:assertEquals( '3 tháng 9 năm 1569 lúc 20:17', Date(datevec,'vi')) end function suite:test_outer_function() -- rest the p.Date(frame) function accessible to template functions self:assertSameResult( '9 January 2009, 15:28:37 +03:30', '{{#invoke:DateI18n/sandbox| Date |year=2009|month=01|day=09|hour=15|minute=28|second=37|tzhour=3|tzmin=30|class=|lang=en}}') self:assertSameResult( '<span style="white-space:nowrap"><time class="dtstart" datetime="2009-01-09">9 stycznia 2009</time></span>', '{{#invoke:DateI18n/sandbox| Date |year=2009|month=01|day=09|class=dtstart|lang=pl}}') self:assertSameResult( '<span style="white-space:nowrap"><time class="dtstart" datetime="2009-01-09">9 styczeń 2009</time></span>', '{{#invoke:DateI18n/sandbox| Date |year=2009|month=01|day=09|case=nom|lang=pl}}') self:assertSameResult( '25 mai 1943, 15:28:37', '{{#invoke:DateI18n/sandbox|Date|year=1943|month=05|day=25|hour=15|minute=28|second=37|class=|lang=fr}}') end function suite:test_timezones() self:assertEquals('9 January 2009, 15:28:37 +03:30', Date({2009,1,9,15,28,37,3,30}, 'en')) self:assertEquals('9 January 2009, 15:28:37 −11:00', Date({2009,1,9,15,28,37,-11} , 'en')) self:assertEquals('ज्यानुवरी ९, ई सं २००९, १५:२८:३७ −११:००', Date({2009,1,9,15,28,37,-11} , 'new')) end function suite:test_gramatical_cases() self:assertEquals( '20 July 1969', Date({1969,07,20},'en','')) self:assertEquals( '21 lipca 1969', Date({1969,07,21},'pl','')) self:assertEquals( '22 lipiec 1969', Date({1969,07,22},'pl','nom')) self:assertEquals( '23 lipca 1969', Date({1969,07,23},'pl','gen')) self:assertEquals( '24 lipcem 1969', Date({1969,07,24},'pl','ins')) self:assertEquals( '25 lipcu 1969', Date({1969,07,25},'pl','loc')) self:assertEquals( '21 июля 1969', Date({1969,07,21},'ru','')) self:assertEquals( '22 июль 1969', Date({1969,07,22},'ru','nom')) self:assertEquals( '23 июля 1969', Date({1969,07,23},'ru','gen')) self:assertEquals( '24 июлем 1969', Date({1969,07,24},'ru','ins')) self:assertEquals( '25 июле 1969', Date({1969,07,25},'ru','loc')) self:assertEquals( 'marraskuu 1960', Date({1960,11},'fi','')) self:assertEquals( 'marraskuu 1961', Date({1961,11},'fi','nom')) self:assertEquals( 'marraskuun 1962', Date({1962,11},'fi','gen')) self:assertEquals( 'marraskuuta 1963', Date({1963,11},'fi','ptv')) self:assertEquals( 'marraskuussa 1964', Date({1964,11},'fi','ine')) self:assertEquals( 'marraskuusta 1965', Date({1965,11},'fi','ela')) self:assertEquals( 'marraskuuhun 1966', Date({1966,11},'fi','ill')) end function suite:test_year_trimming() self:assertEquals( '1 September 999', Date({999, 9, 1}, 'en', '', '', true)) self:assertEquals( '2 September 99', Date({ 99, 9, 2}, 'en', '', '', 'true')) self:assertEquals( '3 September 9', Date({ 9, 9, 3}, 'en', '', '', 1)) self:assertEquals( '4 September 0999', Date({999, 9, 4}, 'en', '', '', false)) self:assertEquals( '5 September 0999', Date({999, 9, 5}, 'en', '', '', 'false')) self:assertEquals( '6 September 999', Date({999, 9, 6}, 'en', '', '', '100-999')) self:assertEquals( '7 September 0999', Date({999, 9, 7}, 'en', '', '', '100-990')) self:assertEquals( '৮ সেপ্টেম্বর ৯৮৭', Date({987, 9, 8}, 'bn', '', '', '1')) self:assertEquals( 'सप्टेंबर ९, इ.स. ९८७', Date({987, 9, 9}, 'mr', '', '', '1')) self:assertEquals( 'ಸೆಪ್ಟೆಂಬರ್ ೧೦, ೯೮೭', Date({987, 9,10}, 'kn', '', '', '1')) end return suite