All tests passed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
![]() | "(%=%=+)(+)%=%=+" | 🗸true | 🗸true |
![]() | "αειου" | 🗸true | 🗸true |
![]() | "" | 🗴false | 🗴false |
![]() | "%" | 🗴false | 🗴false |
![]() | "%" | 🗸true | 🗸true |
![]() | "" | 🗴false | 🗴false |
![]() | "a?" | 🗸true | 🗸true |
![]() | "α?" | 🗴false | 🗴false |
![]() | "a*" | 🗸true | 🗸true |
![]() | "α*" | 🗴false | 🗴false |
![]() | "a-" | 🗸true | 🗸true |
![]() | "α-" | 🗴false | 🗴false |
![]() | "a+" | 🗸true | 🗸true |
![]() | "α+" | 🗴false | 🗴false |
![]() | "a.b" | 🗴false | 🗴false |
local tests = require("Module:UnitTests")
local canUseString = require("Module:User:Erutuon/patterns").canUseString
local highlight = require("Module:debug").highlight
highlight = highlight{ inline = true }
local function LuaString(text)
return highlight('"' .. text .. '"')
end
local function displayBoolean(text)
local color, emoji
if text == "false" then
color = "red"
emoji = "🗴"
elseif text == "true" then
color = "green"
emoji = "🗸"
end
return emoji .. '<code><span style="color: ' .. (color or '') .. ';">' .. text .. '</span></code>'
end
local options = { display = displayBoolean }
function tests:check(example, expected)
self:equals(LuaString(example), canUseString(example), expected, options)
end
tests = function (self)
local examples = {
{ "(%=%=+)(+)%=%=+", true }, -- section heading
{ "αειου", true },
{ "", false }, -- Greek lowercase vowel letter
{ "%", false },
{ "%", true },
{ "", false }, -- needs an actual example
{ "a?", true },
{ "α?", false },
{ "a*", true },
{ "α*", false },
{ "a-", true },
{ "α-", false },
{ "a+", true },
{ "α+", false },
{ "a.b", false },
}
self:iterate(examples, "check")
end
return tests