local function contain(state, arguments)
local expected = arguments[1]
return function(value)
return type(value) == "string" and value:find(expected)
end
end
assert:register("matcher", "contain", contain)
print(matcher.contain("string")("substring")) -- false
It turns out matcher treats all non-true values as false. It should be written like type(value) == "string" and value:find(expected) and true.
If this is expected, it should be documented. I did not find where to create PR or submit patches for documentation.
It turns out matcher treats all non-true values as false. It should be written like
type(value) == "string" and value:find(expected) and true
.If this is expected, it should be documented. I did not find where to create PR or submit patches for documentation.
There's also a typo "you should should".