יחידה:תאריך/בדיקות
ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:תאריך/בדיקות/תיעוד
-- Unit tests for [[Module:תאריך]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local Date = require('יחידה:תאריך')
function p:testNewFromWikitextSimple()
local d = Date.newFromWikitext('3 בפברואר 2000')
self:equals('precision', d.precision, Date.PRECISION.DAY )
self:equals('day ', d.day, 3 )
self:equals('year ', d.month, 2 )
self:equals('year ', d.year, 2000 )
self:equals('calendar ', d.calendar, Date.CALENDAR.GREGORIAN )
end
function p:testNewFromWikitextLink()
local d = Date.newFromWikitext('[[3 בפברואר]] [[2000]]')
self:equals('precision', d.precision, Date.PRECISION.DAY )
self:equals('day ', d.day, 3 )
self:equals('year ', d.month, 2 )
self:equals('year ', d.year, 2000 )
self:equals('calendar ', d.calendar, Date.CALENDAR.GREGORIAN )
end
function p:testNewFromWikitextCentury()
local success, res = pcall(Date.newFromWikitext, 'המאה ה-13' )
self:equals('parse', tostring(success), 'true' )
if success then
self:equals('precision', res.precision, Date.PRECISION.YEAR100 )
self:equals('year', res.year, 1300 ) -- representive year is the last, e.g century pretty format is year/100
self:equals('month', res.month, 0 ) -- not relevant
self:equals('day', res.day, 0 ) -- not relevant
end
end
return p