Module:fun/testcases
Appearance
- The following documentation is located at Module:fun/testcases/documentation. [edit] Categories were auto-generated by Module:documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • tested module • sandbox
All tests passed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
3
| false | false | |
function#1
| true | true | |
table#1 {
}
| false | false | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = table#2
}
| true | true | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = true
}
| false | false | |
table#1 {
}
| false | false | |
table#1 {
metatable = 5
}
| false | false | |
table#1 {
metatable = function#1
}
| false | false | |
table#1 {
metatable = table#2
}
| true | true | |
table#1 {
metatable = table#2
}
| false | false | |
table#1 {
metatable = true
}
| false | false | |
table#1 {
}
| false | false | |
table#1 {
metatable = 5
}
| false | false | |
table#1 {
metatable = function#1
}
| false | false | |
table#1 {
metatable = table#2
}
| true | true | |
table#1 {
metatable = table#2
}
| false | false |
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