Module:User:Erutuon/patterns/testcases

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 .. ' ' end

local options = { display = displayBoolean } function tests:check(example, expected) self:equals(LuaString(example), canUseString(example), expected, options) end

tests["test canUseString"] = function (self) local examples = { { "(%=%=+)([^%=]+)%=%=+", true }, -- section heading { "αειου", true }, { "[αειου]", false }, -- Greek lowercase vowel letter { "%[%%%s%]", false }, { "%[αειου%]", true }, { "[ae][ʊɪ]", 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