------------------------
-- Sandbox module:
-- For testing purposes
------------------------
local function pre( c )
return tostring(
mw.html.create( 'pre' ):wikitext( c ):done()
);
end
return {
['test args'] = function( frame )
local ret = {}
for i, v in ipairs( frame.args ) do
table.insert( ret, '# ' .. v )
end
return table.concat( ret, '\n' )
end,
main = function( frame )
return tostring(
mw.html.create( 'table' )
:addClass( 'wikitable' )
:tag( 'tr' )
:tag( 'th' ):wikitext( 'frame' ):done()
:tag( 'td' ):node( pre( mw.dumpObject( frame ) ) ):done()
:done()
:tag( 'tr' )
:tag( 'th' ):wikitext( 'parent frame' ):done()
:tag( 'td' ):node( pre( mw.dumpObject( frame:getParent() ) ) ):done()
:done()
:tag( 'tr' )
:tag( 'th' ):wikitext( 'current frame' ):done()
:tag( 'td' ):node( pre( mw.dumpObject( mw.getCurrentFrame() ) ) ):done()
:done()
:done()
);
end
}
-- Some set list tests.
-- Just copy to the console.
--[=[
--[===[
Row test:
]===]
local DATA = require( 'Module:Data' )
local Row = require( 'Module:Set list/Row' )
local Renderer = require( 'Module:Set list/Renderer' )
local lnEnglish = DATA.getLanguage( 'en' )
local row = Row(
'ABCD-EN123',
'Some name',
{
DATA.getRarity( 'R' ),
DATA.getRarity( 'ScR' ),
DATA.getRarity( 'UtR' ),
},
{
{
name = 'Volume',
key = 'volume',
value = '[[Yu-Gi-Oh! ZEXAL Volume 1 promotional card|Volume 1]]',
},
{
name = 'Col with Spaces',
key = '??',
value = 'How to handle spaces for the key?',
},
},
setmetatable(
{
quantity = '1',
},
{
__index = {
['print'] = 'Reprint',
}
}
)
)
local renderer = Renderer( lnEnglish )
mw.log(
row:render( renderer )
)
mw.logObject( renderer )
--]=]
--[=[
--[===[
CardList test:
]===]
local DATA = require( 'Module:Data' )
local Row = require( 'Module:Set list/Row' )
local CardList = require( 'Module:Set list/CardList' )
local Renderer = require( 'Module:Set list/Renderer' )
local lnEnglish = DATA.getLanguage( 'en' )
local cardList = CardList(
'Test header',
{
DATA.getRarity( 'R' ),
DATA.getRarity( 'ScR' ),
DATA.getRarity( 'UtR' ),
length = 3,
},
{
{
name = 'Volume',
key = 'volume',
},
{
name = 'Col with Spaces',
key = '??',
},
},
{
quantity = '2',
['print'] = 'Reprint',
}
)
cardList
:addRow(
'ABCD-EN123',
'Some name',
{
DATA.getRarity( 'C' ),
length = 1,
},
{
{
name = 'Volume',
key = 'volume',
value = '[[Yu-Gi-Oh! ZEXAL Volume 1 promotional card|Volume 1]]',
},
{
name = 'Col with Spaces',
key = '??',
value = 'How to handle spaces for the key?',
},
},
{
quantity = '1',
}
)
:addRow(
'EFGH-EN456',
'Some name 2',
{
length = 0,
},
{
{
name = 'Volume',
key = 'volume',
value = '[[Yu-Gi-Oh! ZEXAL Volume 2 promotional card|Volume 2]]',
},
{
name = 'Col with Spaces',
key = '??',
value = 'How to handle spaces for the key? 2',
},
},
{
['print'] = 'Reprint in EU only',
}
)
local renderer = Renderer( lnEnglish )
mw.log(
cardList:render( renderer )
)
mw.logObject( renderer )
--]=]