Module:Yesno/testcases: Difference between revisions

Content deleted Content added
+test cases for t, T, f, and F
test live module alongside the sandbox (refactor; extract compareLiveAndSandbox; fix message in runYesnoTestWithDefault)
 
(2 intermediate revisions by the same user not shown)
Line 1:
local yesno = require('Module:Yesno/sandbox')
local yesnoSandbox = require('Module:Yesno/sandbox')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
 
local function compareLiveAndSandbox(expected, liveValue, sandboxValue)
local message = "Expected " .. tostring(expected) .. ". Got " ..
suite:assertEquals(expected, yesno(inputValue)liveValue, message .. " from sandbox"tostring(liveValue)
message .. " from sandboxlive module.")
suite:assertEquals(expected, sandboxValue, message .. tostring(sandboxValue)
.. " from sandbox.")
end
 
local function runYesnoTest(expected, inputValue)
local liveValue = yesno(inputValue)
local message = "Expected " .. tostring(expected) .. ". Got " ..
tostring(yesno local sandboxValue = yesnoSandbox(inputValue))
compareLiveAndSandbox(expected, liveValue, sandboxValue)
suite:assertEquals(expected, yesno(inputValue), message .. " from sandbox")
end
 
local function runYesnoTestWithDefault(expected, inputValue)
local liveValue = yesno(inputValue, 'default')
local message = "Expected " .. tostring(expected) .. ". Got " ..
tostring(yesno local sandboxValue = yesnoSandbox(inputValue), 'default')
suite:assertEqualscompareLiveAndSandbox(expected, yesno(inputValueliveValue, 'default'sandboxValue),
message .. " from sandbox")
end