Module:fun/testcases

Hello, you have come here looking for the meaning of the word Module:fun/testcases. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:fun/testcases, but we will also tell you about its etymology, its characteristics and you will know how to say Module:fun/testcases in singular and plural. Everything you need to know about the word Module:fun/testcases you have here. The definition of the word Module:fun/testcases will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:fun/testcases, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

All tests passed. (refresh)

TextExpectedActual
test_is_callable:
Passed
3
falsefalse
Passed
function#1
truetrue
Passed
table#1 {
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
truetrue
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = true
}
falsefalse
Passed
table#1 {
}
falsefalse
Passed
table#1 {
    metatable = 5
}
falsefalse
Passed
table#1 {
    metatable = function#1
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
truetrue
Passed
table#1 {
    metatable = table#2
}
falsefalse
Passed
table#1 {
    metatable = true
}
falsefalse
Passed
table#1 {
}
falsefalse
Passed
table#1 {
    metatable = 5
}
falsefalse
Passed
table#1 {
    metatable = function#1
}
falsefalse
Passed
table#1 {
    metatable = table#2
}
truetrue
Passed
table#1 {
    metatable = table#2
}
falsefalse

local tests = require("Module:UnitTests")

local highlight = require("Module:debug").highlight{ lang = "text"}
local is_callable = require("Module:fun").is_callable

function tests:check_is_callable(obj, expected)
	tests:equals(highlight(mw.dumpObject(obj)), is_callable(obj), expected)
end

function tests:test_is_callable()
	local example = setmetatable({}, {__call = function() end})
	
	local examples = {
		{3, false},
		{function() end, true},
		{{}, false},
		{setmetatable({}, {}), false},
		{setmetatable({}, {__index = {}}), false},
		{example, true},
		{setmetatable({}, {__call = {}}), false},
		{setmetatable({}, {__call = example}), false},
		{setmetatable({}, setmetatable({}, {__index = {__call = function() end}})), false},
		{setmetatable({}, {__metatable = {}}), false},
		{setmetatable({}, {__metatable = true}), false},
		{setmetatable({}, {__metatable = false}), false},
		{setmetatable({}, {__metatable = 5}), false},
		{setmetatable({}, {__metatable = function() end}), false},
		{setmetatable({}, setmetatable({__call = function() end}, {__index = {__metatable = false}})), true},
		{setmetatable({}, {__call = function() end, __metatable = {}}), false},
		{setmetatable({}, {__call = function() end, __metatable = true}), false},
		{setmetatable({}, {__call = function() end, __metatable = false}), false},
		{setmetatable({}, {__call = function() end, __metatable = 5}), false},
		{setmetatable({}, {__call = function() end, __metatable = function() end}), false},
		{setmetatable({}, {__call = function() end, __metatable = {__call = function() end}}), true},
		{setmetatable({}, setmetatable({}, {__index = {__call = function() end, __metatable = false}})), false},
	}

	self:iterate(examples, "check_is_callable")
end

return tests