Module:Repr/testcases
Appearance
![]() | This is the test cases page for the module Module:Repr. Results of the test cases. |
-- Load necessary modules
local mRepr = require('Module:Repr')
local ScribuntoUnit = require('Module:ScribuntoUnit')
-- Initialise test suite
local suite = ScribuntoUnit:new()
local reprTestData = {
{
testName = "testRepr_nil",
args = {nil, {}},
expected = 'nil',
},
{
testName = "testRepr_true",
args = {true, {}},
expected = 'true',
},
{
testName = "testRepr_false",
args = {false, {}},
expected = 'false',
},
{
testName = "testRepr_integer",
args = {7, {}},
expected = '7',
},
{
testName = "testRepr_float",
args = {3.14159, {}},
expected = '3.14159',
},
{
testName = "testRepr_emptyString",
args = {"", {}},
expected = '""',
},
{
testName = "testRepr_normalString",
args = {"foo", {}},
expected = '"foo"',
},
{
testName = "testRepr_stringWithQuotes",
args = {'"foo"', {}},
expected = '\\"foo\\"',
},
}
for _, testData in ipairs(reprTestData) do
suite[testData.testName] = function(self)
local result = mRepr.repr(unpack(testData.args))
self:assertEquals(result, testData.expected)
end
end
return suite