-- Pangsubok a kaskaso para iti [[Modulo:Napalabas a panawen]]. Pinduten ti tungtunganna a panid tapno maipataray dagiti pangsubok.
local p = require('Modulo:UnitTests')
function p:test_main()
local lang = mw.language.getContentLanguage()
-- Calculate the time since/until the test dates here, since the expected output is dependent on the current time in most cases.
local currentTime = lang:formatDate( 'U' )
local jul09 = currentTime - lang:formatDate( 'U', '1 July 2009' )
local secondssincejul09 = math.floor( jul09 )
local minutessincejul09 = math.floor( jul09 / 60 )
local dayssincejul09 = math.floor( jul09 / 86400 )
local weekssincejul09 = math.floor( jul09 / 604800 )
local monthssincejul09 = math.floor( jul09 / 2678400 )
local yearssincejul09 = math.floor( jul09 / 31557600 )
local monthssincesep13 = math.floor( ( currentTime - lang:formatDate( 'U', '15 September 2013' ) ) / 2678400 )
local monthsuntiljul49 = math.floor( ( lang:formatDate ( 'U', '1 July 2049' ) - currentTime ) / 2678400 )
local yearsuntilaug57 = math.floor( ( lang:formatDate ( 'U', '4 August 2057' ) - currentTime ) / 31557600 )
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|15 September 2013}}', monthssincesep13 .. ' a bulbulan ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{CURRENTTIMESTAMP}}}}', '0 a segsegundo ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|15 September 2013|purge=yes}}', monthssincesep13 .. ' a bulbulan ti napalabas <span class="plainlinks">([//ilo.wikipedia.org/w/index.php?title=Modulo_tungtungan:Napalabas_a_panawen/pangsubok&action=purge purgaen])</span>')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{CURRENTTIMESTAMP}}|purge=yes}}', '0 a segsegundo ti napalabas <span class="plainlinks">([//ilo.wikipedia.org/w/index.php?title=Modulo_tungtungan:Napalabas_a_panawen/pangsubok&action=purge purgaen])</span>')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009}}', yearssincejul09 .. ' a tawtawen ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=minutes}}', minutessincejul09 .. ' a minminuto ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=days}}', dayssincejul09 .. ' nga al-aldaw ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=weeks}}', weekssincejul09 .. ' a lawlawas ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=months}}', monthssincejul09 .. ' a bulbulan ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2049|magnitude=months}}', monthsuntiljul49 .. ' a bulbulan ti masakbayan')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|Julio 1}}', '<strong class="error">Biddut: saan a maiwaswas ti umuna a parametro a kas petsa wenno oras.</strong>')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=fruits}}', secondssincejul09 .. ' a segsegundo ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main}}', '0 a segsegundo ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=HoUrS}}', secondssincejul09 .. ' a segsegundo ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|4 August 2057}}', yearsuntilaug57 .. ' a tawtawen ti masakbayan')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|15 September 2013|ago=iti napalabas}}', monthssincesep13 .. ' a bulbulan iti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{CURRENTTIMESTAMP}}|min_magnitude=weeks}}', '0 a lawlawas ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|15 September 2013|ago=}}', monthssincesep13 .. ' a bulbulan')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=yes}}', 'sangapulo ket dua a bulbulan ti napalabas') -- #time always gives one month too few
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=y}}', 'sangapulo ket dua a bulbulan ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=y|spelloutmax=11}}', '12 a bulbulan ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=auto}}', '12 a bulbulan ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|{{#time: r | -4 years -14 days}}|magnitude=years|spellout=auto}}', 'uppat a tawtawen ti napalabas')
self:preprocess_equals('{{#invoke:Napalabas a panawen|main|July 1 2009|magnitude=weeks|spellout=yes}}', weekssincejul09 .. ' a lawlawas ti napalabas') -- [[Module:NumberSpell]] can only spell numbers up to 100.
self:preprocess_equals_preprocess('{{#invoke:Napalabas a panawen|main|{{REVISIONTIMESTAMP}}|magnitude=days}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}})/86400)}} nga al-aldaw ti napalabas')
self:preprocess_equals_preprocess('{{#invoke:Napalabas a panawen|main|{{REVISIONTIMESTAMP}}|magnitude=hours}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}})/3600)}} nga or-oras ti napalabas')
self:preprocess_equals_preprocess('{{#invoke:Napalabas a panawen|main|{{REVISIONTIMESTAMP}}|magnitude=minutes}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}})/60)}} a minminuto ti napalabas')
self:preprocess_equals_preprocess('{{#invoke:Napalabas a panawen|main|{{REVISIONTIMESTAMP}}|magnitude=seconds}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}}))}} a segsegundo ti napalabas')
end
return p