Saltar para o conteúdo

Módulo:Calendário/Testes unitários

Origem: Wikipédia, a enciclopédia livre.
-- Testes unitários para o [[Módulo:Calendário]]. Clique na página de discussão para rodar os testes.
local p = require('Módulo:UnitTests')

function p:test_gregorian2julian()
	self:preprocess_equals('{{#invoke:Calendário|Gregorian2Julian|+2018-12-30}}', '17-12-2018')
	self:preprocess_equals('{{#invoke:Calendário|Gregorian2Julian|+2000-01-01}}', '19-12-1999')
	self:preprocess_equals('{{#invoke:Calendário|Gregorian2Julian|+1901-01-01}}', '19-12-1900')
	self:preprocess_equals('{{#invoke:Calendário|Gregorian2Julian|+1900-01-01}}', '20-12-1899')
	self:preprocess_equals('{{#invoke:Calendário|Gregorian2Julian|+30-12-2018}}', 'Erro ao passar data: +30-12-2018')
end

function p:test_julian2gregorian()
	self:preprocess_equals('{{#invoke:Calendário|Julian2Gregorian|+2018-12-17}}', '30-12-2018')
	self:preprocess_equals('{{#invoke:Calendário|Julian2Gregorian|+1999-12-19}}', '01-01-2000')
	self:preprocess_equals('{{#invoke:Calendário|Julian2Gregorian|+1900-12-19}}', '01-01-1901')
	self:preprocess_equals('{{#invoke:Calendário|Julian2Gregorian|+1899-12-20}}', '01-01-1900')
	self:preprocess_equals('{{#invoke:Calendário|Julian2Gregorian|+30-12-2018}}', 'Erro ao passar data: +30-12-2018')
end

function p:test_dayofweek()
	self:preprocess_equals('{{#invoke:Calendário|DayOfWeek|+2018-12-30}}', 'domingo')
	self:preprocess_equals('{{#invoke:Calendário|DayOfWeek|+2000-01-01}}', 'sábado')
	self:preprocess_equals('{{#invoke:Calendário|DayOfWeek|+1901-01-01}}', 'terça-feira')
	self:preprocess_equals('{{#invoke:Calendário|DayOfWeek|+1900-01-01}}', 'segunda-feira')
	self:preprocess_equals('{{#invoke:Calendário|DayOfWeek|+30-12-2018}}', 'Erro ao passar data: +30-12-2018')
end

function p:test_date2jdn()
	self:preprocess_equals('{{#invoke:Calendário|date2jdn|+2018-12-30|1}}', '2458483')
	self:preprocess_equals('{{#invoke:Calendário|date2jdn|+2018-12-17|0}}', '2458483')
end

return p