Module:Sandbox

local _entity

local p = {} function p.hello return "Hello, world!" end

function p.check(frame) return entityCheck(frame.args[1]) end

function entityCheck(entityId) if string.match(entityId, '^[PQ]%d+$') == nil then return entityId .. ': Invalid entity id' end

if mw.wikibase.getEntity(entityId) then return entityId .. ': Does exist' else return entityId .. ': Does not exist' end end

function p.pcall_check(frame) return pcall_entityCheck(frame.args[1]) end

function pcall_entityCheck(entityId) if string.match(entityId, '^[PQ]%d+$') == nil then return entityId .. ': Invalid entity id' end

local test, result test, result = pcall(mw.wikibase.getEntity, entityId) if test then return entityId .. ': Does exist' else return entityId .. ': Does not exist' end end

function p.xpcall_check(frame) _entity = frame.args[1] if string.match(_entity, '^[PQ]%d+$') == nil then return _entity .. ': Invalid entity id' end

local function f (id) return mw.wikibase.getEntity(id) end

local function err (x) return "invalid id" end

local function check_id return f(_entity) end

status, err = xpcall (check_id, err)

if status then return _entity .. ': Does exist' else return _entity .. ': Does not exist' end end

function p.test_ja_wiki (frame) return '魚雷前期型' end

return p