Ugrás a tartalomhoz

Modul:Time/tests

A Wikipédiából, a szabad enciklopédiából
A lap korábbi változatát látod, amilyen 81.182.250.189 (vitalap) 2013. november 20., 13:20-kor történt szerkesztése után volt. Ez a változat jelentősen eltérhet az aktuális változattól.

Time modul tesztek[mi ez?]

Név Várt Tényleges
testFormatDate Lua error -- Modul:Time/tests:23: attempt to call field 'newFromIso8061' (a nil value)
testNew Lua error -- Modul:Time/tests:6: attempt to call field 'newFromIso8061' (a nil value)
testAge Lua error -- Modul:Time/tests:14: attempt to call field 'newFromIso8061' (a nil value)
local Time = require('Modul:Time')
local ScribuntoUnit = require('Modul:ScribuntoUnit')
local suite = ScribuntoUnit:new()

function suite:testNew()
    self:assertEquals('2013-10-23', Time.newFromIso8061('2013-10-23'):toString())
    local status, value = pcall(function () return mw.wikibase.getEntity().claims['p569'][0].mainsnak.datavalue.value end)
    if status then
        self:assertEquals('2012-10-23', Time.newFromWikidataValue(value):toString())
    end
end

function suite:testAge()
    local time1 = Time.newFromIso8061('2003-11-09')
    local time2 = Time.newFromIso8061('2013-12-09')
    local time3 = Time.newFromIso8061('2013-10-09')
    self:assertEquals(10, Time.age(time1, time2))
    self:assertEquals(9, Time.age(time1, time3))
    self:assertTrue(Time.age(time1) >= 10)
end

function suite:testFormatDate()
    local t = Time.newFromIso8061('-00000000322-06-05T00:00:00Z')
    t.calendar = Time.CALENDAR.JULIAN
    self:assertEquals('[[i. e. 323]]. [[június 10.]]', t:formatDate())
    self:assertEquals('2013. október 23.', Time.newFromIso8061('2013-01-23'):formatDate({link = 'nem'}))
    self:assertEquals('1655', Time.newFromIso8061('1655'):formatDate({link = 'nem'}))
end

return suite