Module:Template test case: Difference between revisions

    (move Template.outputEquals to the TestCase class)
    (move the render methods table to the base of the TestCase class)
    Line 127: Line 127:
    local TestCase = {}
    local TestCase = {}
    TestCase.__index = TestCase
    TestCase.__index = TestCase
    TestCase.renderMethods = {
    -- Keys in this table are values of the "format" option, values are the
    -- method for rendering that format.
    columns = 'renderColumns',
    rows = 'renderRows',
    default = 'renderDefault'
    }


    function TestCase.new(invocationObj, options, cfg)
    function TestCase.new(invocationObj, options, cfg)
    Line 342: Line 350:


    function TestCase:__tostring()
    function TestCase:__tostring()
    local methods = {
    collapsed = 'renderCollapsed',
    columns = 'renderColumns',
    rows = 'renderRows'
    }
    local format = self.options.format
    local format = self.options.format
    local method = format and methods[format] or 'renderDefault'
    local method = format and TestCase.renderMethods[format] or 'renderDefault'
    local ret = self[method](self)
    local ret = self[method](self)
    if self.options.collapsible then
    if self.options.collapsible then